javascript如何禁止鼠标向下滚动

如题所述

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>判断滚动条的滚动方向</title>
<script src="http://www.sucaijiayuan.com/statics/97zzw/js/jquery.js?v=1.83.min" type="text/javascript"></script>
<script>
var initTop = 0;
$(window).scroll(function(){
 var scrollTop = $(document).scrollTop();
 if(scrollTop > initTop){
  $("body").scrollTop(0);
 } else {
  $("body").scrollTop(0);
 }
 initTop = scrollTop;
});
</script>
</head>
<body style="height:3000px;">
</body>
</html>


把代码复制到本地运行一下看看。

温馨提示:内容为网友见解,仅供参考
第1个回答  2016-08-05
那个jquery失效了。可以使用这个:,但是这个方法只是一个判断,如果一直滑动滚动条的话,那就会有guichu动画。如果是禁用事件就好了

烦死了。百度不让评论里发链接,加了中文也没用
http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
相似回答