Monday 9 February 2015

jquery parallax background image

$(document).ready(function(jQuery) {

    $('.my_testimonial').each(function($) {

// assigning the object
var bgobj = jQuery(".my_testimonial");

        jQuery(window).scroll(function($){

            var sco_top = jQuery(window).scrollTop();
            var yPos = -(sco_top / 1.7);

            // Put together our final background position
            var coords = '50% ' + yPos + 'px';
            console.log(coords);

            // Move the background
            jQuery(".my_testimonial").css("backgroundPosition", coords);

        });
    });

});

No comments:

Post a Comment