how to get content between 1300 and 4200 heights (scrollTop) values using jquery
some times the start and end values may be different
how to get content between 1300 and 4200 heights (scrollTop) values using jquery
some times the start and end values may be different
Here's a snippet which looks for elements whose top offsets are between 1300 and 4200 pixels, saving them to an element array arr
:
var items = document.body.getElementsByTagName("*");
var arr = [];
$.each(items, function (i, ele) {
var offset = $(ele).offset();
if (offset && offset.top >= 1300 && offset.top <= 4200) {
arr.push(ele);
}
});
It relies on jQuery's offset function, which does not take into account any margins/padding on the body element. Results may also be off if the browser is not at 100% zoom (there are more details in the jQuery documentation).
I hope it's useful as a starting point.