0

I want to get all the href elements of the page that are really shown to the user in the current time (only what inside the browser frame, not the parts that above or under).

For example, if the user is scrolling down in the page, I want to get in my javascript other elements.

Can I even do it? And if not, can I do from Chrome extension?

Ygandelsman
  • 453
  • 7
  • 16

1 Answers1

2

Try

var res = [];
$("a").each(function(i, el) {
  if (el.getBoundingClientRect().bottom <= window.innerHeight) {
    res.push($(el).eq(i));
    $(el).css({"color":"red", "border":"1px solid red"})
  };
});
console.log($("a").size(), res.length, res);
guest271314
  • 1
  • 15
  • 104
  • 177