我试图在最新的谷歌浏览器中阻止使用鼠标滚轮进行父滚动,但它不起作用。所以我需要对代码进行一些解释。
$(function() {
var toolbox = $('#68').find('.medium-folder-body'),
//The medium-folder-body height - 500px here
height = toolbox.height(),
//scrollHeight 693px (I got the height but don't understand what is that for)
//what is .get(0) ?
scrollHeight = toolbox.get(0).scrollHeight;
toolbox.bind('mousewheel', function(e, d) {
//This is js question which I don't understand often - What is 'this'?
//Second question. What is d?
if((this.scrollTop === (scrollHeight - height) && d < 0) || (this.scrollTop === 0 && d > 0)) {
alert(this.scrollTop);
}
});
});
HTML非常混乱。我在这里说得很简单
<div class="folder">
<div class="header"></div>
<div class="medium-folder-body">
<ul class="photo-lists></ul>
</div>
<div class="footer"></div>
</div>
folder-body css height:500px overflow-y:scroll
答案 0 :(得分:1)
您没有包含处理鼠标滚轮方向数据的附加插件:
<script src="https://github.com/brandonaaron/jquery-mousewheel/raw/master/jquery.mousewheel.js"></script>