简体   繁体   English

未捕获的类型错误鼠标滚轮不是一个功能

[英]Uncaught Type error mousewheel is not a function

I am trying to get an image to be able to be zoom in on when you scroll the mouse wheel. 我试图让你的图像能够在滚动鼠标滚轮时放大。 I'm using jQuery.mousewheel.min to execute this function but no matter I do I get this error in the console 我正在使用jQuery.mousewheel.min来执行此功能,但无论如何我都在控制台中收到此错误

Uncaught TypeError: $(...).mousewheel is not a function 未捕获的TypeError:$(...)。mousewheel不是函数

here is a code sample 这是一个代码示例

<script type="text/javascript">
  $(document).ready(function() {
        $(document).mousewheel(function(event, delta) {
              setYPos(delta);

so basically i'm asking if someone could help me troubleshoot this problem could it maybe be one of these inter fairing with it. 所以基本上我问的是否有人可以帮我解决这个问题,这可能是其中一个与它相互影响。

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="kinetic-v5.1.0.min.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="jquery.mousewheel.min.js" type="text/javascript"></script>
<link href="easy-sidebar.css" rel="stylesheet" type="text/css">

$.mousewheel is not part of the jQuery API. $ .mousewheel不是jQuery API的一部分。

http://api.jquery.com/?s=mouse http://api.jquery.com/?s=mouse

For what it sounds like you're trying to do, you need to use a more specific selector, catch the scroll, read the direction and distance, and prevent default so it doesn't scroll the window - $('img').on('scroll', function(e) { e.preventDefault(); // do some stuff }); 对于你想要做的事情,你需要使用更具体的选择器,捕捉滚动,读取方向和距离,并防止默认,因此它不会滚动窗口 - $('img').on('scroll', function(e) { e.preventDefault(); // do some stuff });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM