监听某个区域滚动_如何用js监听滚动条滚动事件

展开全部

js监视滚动事件的函数是onscroll

js语法:element.onscroll = functionReference

html语法:

使用方法:html>

#container {

position: absolute;

height: auto;

top: 0;

bottom: 0;

width: auto;

left: 0;

right: 0;

overflow: auto;

}

#foo {

height:1000px;

width:1000px;

background-color: #777;

display: block;

}

// js绑定你需要监控32313133353236313431303231363533e4b893e5b19e31333361313861滚动事件的dom,也可以绑定document.body监控整个网页滚动

// 也可以监控具体的dom滚动,像下面的container Id对象

document.getElementById('container').onscroll = function() {

console.log("scrolling");

};


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部