While scrolling a scrollable div on a pop-up, I need the y coordinates, using window.scrollY return y coordinates of background body, not of popup. Is there any way to achieve this?
Just add a scroll event to the element which is scrollable.
const div = document.getElementById("myDiv");
div.addEventListener("scroll", (e)=> {
console.log("scrollTop: " + e.scrollTop);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.