Languages
[Edit]
EN

JavaScript - check if element is visible on part of web page because of scrolling

7 points
Created by:
lena
714

In this article, we're going to have a look at how to check with JavaScript if element is visible on screen or not during scrolling in JavaScript.

This kind of script can be used to detect if image is in visible part of web page and sould be loaded to prevent unnecessary content loading.

 

Page scrolling example

Edit

In this section, presented solution shows how to check if element visibility if is located on page.

Presented script is universal because as container we can use window object or any element.

 

Nested element scrolling example

Edit

In this section, presented solution shows how to check if element visibility if is located in another scollable element.

This is same script like above presented but used with element container.

 

Alternative titles

  1. JavaScript - check if element is visible on scrolled page / inside container
  2. JavaScript - detect element visibility on scrolling
  3. JavaScript - check element visibility on scrolling
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join