评论

收藏

[jQuery] jQuery 鼠标滚轮插件 mousewheel

开发技术 开发技术 发布于:2021-07-30 13:47 | 阅读数:516 | 评论:0

<!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>

DSC0000.png



关注下面的标签,发现更多相似文章