so trying image have parallax scrolling effect, buts not working. got idea on why isnt working?
$(function() { // cache window object var $window = $(window); // parallax backgrounds // tutorial: http://code.tutsplus.com/tutorials/a-simple-parallax-scrolling-technique--net-27641 $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // assigning object $(window).scroll(function() { // scroll background @ var speed // ypos negative value because we're scrolling up! var ypos = -($window.scrolltop() / $bgobj.data('speed')); // put our final background position var coords = '50% '+ ypos + 'px'; // move background $bgobj.css({ backgroundposition: coords }); }); // end window scroll }); });
you need change this:
$('section[data-type="background"]').each(function(){...
to this:
$('div[data-type="background"]').each(function(){...
the backgrounds aren't applied section element. applied div element.
also, don't forget include jquery/jquery ui in fiddles.
updated fiddle: https://jsfiddle.net/0382k30q/7/
Comments
Post a Comment