I am trying to set opacity for some images based on each current offset . The problem is that opacity is not equal to all images if you scroll far down.
What I'm trying to accomplish for each image:
Currently, it only works for the first 2-3 images. All further down are not set from 0-1 , and not from 0.5-40 or otherwise.
Another problem is that if the scroll offset is 0 , all images are hidden ...
What i have done so far:
var $win = $(window); var $img = $('img'); $win.on('scroll', function () { var scrollTop = $win.scrollTop(); $img.each(function () { var $self = $(this); $self.css({ opacity: scrollTop / $self.offset().top }); }); }).scroll();
http://jsfiddle.net/ARTsinn/c5SUC/0/
Any ideas on how to get this working?
source share