唐伯虎 发表于 2021-7-30 13:47:40

jQuery 鼠标滚轮插件 mousewheel

<!DOCTYPE html>
<html>
<head>
<title>jQuery 鼠标滚轮插件 mousewheel</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
    .mousewheel {
      background: green;
      width: 200px;
      height: 200px;
    }
</style>
</head>
<body>
    <div class="mousewheel"></div>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
<script src="https://cdn.bootcss.com/jquery-mousewheel/3.1.13/jquery.mousewheel.js"></script>
<script type="text/javascript">
    $('.mousewheel').bind('mousewheel', function(event, delta) {
      var dir = delta > 0 ? 'Up' : 'Down';
      if (dir == 'Up') {
            $('.mousewheel').text('Up');
      } else {
            $('.mousewheel').text('Down');
      }
    });
</script>
</body>
</html>



文档来源:51CTO技术博客https://blog.51cto.com/u_15315190/3202263
页: [1]
查看完整版本: jQuery 鼠标滚轮插件 mousewheel