I have a table wherein the rows are of different height but are divisible by a certain value. If I scroll down to the middle of the table, is there a way that I will know what rows are displayed and how many are there?
Something like this would work. I haven't had a chance to test it yet. I will try and put a fiddle up in a bit.
I would use this with a throttle on the scroll trigger if you are going to implement it in live, otherwise it would be very intensive for your page to handle.
$(window).on('scroll', function () {
var top = $(window).scrollTop();
var rows = $('.my-table tr');
var range = 100;
rows.each(function () {
var offsetTop = $(this).offset().top;
if (offsetTop - top >= 0 && offsetTop - top <= range) {
console.log("This is the row at the top of the page");
});
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments