jQuery: Run when scroll over a div of a certain class

so I have multiple divs of the same class below each other. I now want to trigger a "loading comments"-function every time a visitor scrolls to a new div. However, I have no idea how to track jQuery scroll over a div. The comments for each div should only be loaded once, my idea would be to save the current position in a variable and only load comments when the new scroll position is greater than the old one.

Can you please help me out?

EDIT: I created a image that shows what I need to do. Image: http://i.imgur.com/78EYK.jpg

EDIT 2: SOLVED! Solved with Viewport (thanks to Royi Namir) http://www.appelsiini.net/projects/viewport

My code:

load = $(".my-div:in-viewport").attr('id');

This is executed every second.


you should read about viewport

Viewport ads couple of extra selectors to jQuery. With these selectors you can check whether element is inside or outside of viewport. To see how it works check the demo.


Need Your Help

How can I sort excel file by the first column? java

java mysql sorting

i have to make a program where we read data from excel files as the one here and store them in a table in mysql with descending ID.

JMOL pdb files not being served

java iis asp.net-mvc-2

I am building an asp.net mvc web site which needs to host some JMOL content.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.