javascript - jqueryeffect() 函数无法识别

标签 javascript jquery html

我在使用 jQueryeffect() 函数在图像上创建反弹效果时遇到问题。 实际上是使用这段代码(调用jQuery库后的代码):

$(document).ready(function() {
  $('#arrow-disclaimer').bind('mouseenter', function(){
  $(this).effect('bounce',500);
  });
});
//Here there isn't the jQuery library, but in the page is included before jqueryUI

<link rel="stylesheet" type="text/css" href="css/style-disclaimer.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/i18n/jquery-ui-i18n.js"></script>
<a href="#disclaimer-p">
  <img src="images/arrow483.png" id="arrow-disclaimer" />
</a>

有人可以告诉我为什么会出现此错误吗?

Uncaught TypeError: $(...).effect is not a function

最佳答案

  1. 您需要加载 jQuery 才能使用 jQuery-ui 或任何其他依赖插件
  2. 您使用的 jquery-ui-i18n 仅用于国际化。您需要包含 jquery-ui 主库,并且如果您想使用 i18n,请将其包含在 jquery-ui 之后。
  3. bind在 jQuery 版本 1.7 中已弃用,请使用 on .

$(document).ready(function() {
  $('#arrow-disclaimer').on('mouseenter', function() {
    $(this).effect('bounce', 500);
  });
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<a href="#disclaimer-p">
  <img src="images/arrow483.png" id="arrow-disclaimer" />
</a>

关于javascript - jqueryeffect() 函数无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34417241/

相关文章:

javascript - 在javascript中将一个简单的java对象重新排序为3级对象

javascript - 点击 fancybox 弹出窗口时需要弹出 Fancy 框

java - 将桌面应用程序转换为服务器+浏览器应用程序

html - Chrome 和 Firefox 中的模糊文本

javascript - Highcharts - 在两列中显示饼图的图例

javascript - 我可以保存一个文件,该文件将仅使用 javascript/C/C++ 在服务器端从 php 代码生成,并且没有打开浏览器吗?

javascript - 如何最好地编写重叠的 html 按钮

html - 左浮动 div 的 100% 背景,其中另一个右浮动 div 超过左

html - 具有 `position: relative;` 和较小字体的高度差 div

javascript - 防止在加载页面上滚动