跳至主要內容

查看页面滚动节点

望间代码JavaScript小于 1 分钟

查看页面滚动节点

将下面代码在浏览器中执行,就会打印滚动的节点

function findScroller(element) {
  element.onscroll = function () {
    console.log(element);
  };
  Array.from(element.children).forEach(findScroller);
}
findScroller(document.body);
上次编辑于:
贡献者: ViewRoom