Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

detect when page scroll to div javascript no jquery

window.addEventListener("scroll", function() {
  var elementTarget = document.getElementById("section-2");
  if (window.scrollY > (elementTarget.offsetTop + elementTarget.offsetHeight)) {
      alert("You've scrolled past the second div");
  }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #detect #page #scroll #div #javascript #jquery
ADD COMMENT
Topic
Name
1+8 =