Answers for "detect when page scroll to div javascript no jquery"

0

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");
  }
});
Posted by: Guest on May-27-2021

Code answers related to "detect when page scroll to div javascript no jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language