window.addEventListener(
"scroll",
function (e) {
var el = e.target;
while (el && el !== document && !isScrollable(el)) {
el = el.parent;
}
console.log("Scrolled element: " + (el.className || "document"));
},
true
);
function isScrollable(el) {
return (
el.scrollWidth > el.clientWidth || el.scrollHeight > el.clientHeight
);
}
查找页面滚动元素
最新推荐文章于 2024-07-26 11:41:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)