Hello there guys
I have javascript code for parallex effect its working great but what I need is to transform this code to jquery so my site contain only jquery codes not mixed.

<script>
    var topDiv = document.getElementById("topDiv");
    var speed = 1.5;
    window.onscroll = function()
    {
        var yOffset = window.pageYOffset;
        topDiv.style.backgroundPosition = "0px "+ (yOffset / speed) + "px";
    }
</script>
<script>
    var topDiv = $("#topDiv");
    var speed = 1.5;
    $(window).scroll(function(){
        var yOffset = $(window).pageYOffset;
        topDiv.style.backgroundPosition = "0px "+ (yOffset / speed) + "px";
    });
</script>

BTW I reached this step but its not working .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.