首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不工作阻止使用鼠标滚轮js滚动父对象

不工作阻止使用鼠标滚轮js滚动父对象
EN

Stack Overflow用户
提问于 2013-01-27 07:46:10
回答 1查看 454关注 0票数 0

在最新的谷歌Chrome浏览器中,我试图阻止家长使用鼠标滚轮滚动,但它不起作用。所以我需要一些代码的解释。

代码语言:javascript
复制
$(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很乱。我在这里让它变得简单

代码语言:javascript
复制
<div class="folder">
   <div class="header"></div>
   <div class="medium-folder-body">
     <ul class="photo-lists></ul>
   </div>
   <div class="footer"></div>
</div>

文件夹体css height:500px overflow-y:scroll

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-27 08:22:20

您没有包含处理鼠标滚轮滚动方向数据的附加插件:

代码语言:javascript
复制
<script src="https://github.com/brandonaaron/jquery-mousewheel/raw/master/jquery.mousewheel.js"></script>

http://jsfiddle.net/ExplosionPIlls/ZQgfr/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14542802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档