Return which image from a vertical list is currently in the viewport with jQuery? -
i have vertical list of images user scrolls view. how can make jquery tell me image in viewport?
here fiddle close want. http://jsfiddle.net/y6pjg/
what change border if image more 30 pixels top. want change if statement check position bottom.
$(document).ready(function() { // check on page load docheck(); // check on scroll $(window).scroll(function(){ docheck(); }); }); function docheck(){ $('#list li').each(function(index){ var item = $(this); if((item.offset().top - $(window).scrolltop()) > 30){ item.css('border-style', 'solid'); }else{ item.css('border-style', 'none'); } }); }
Comments
Post a Comment