2015-12-22 48 views
0

我有一個問題,使用jQuery effect()函數在圖像上創建反彈效果。 其實是使用此代碼(代碼調用jQuery庫後):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

+0

jQuery的UI需要的jQuery和jQuery應該把它的所有家屬之前加載。 – Tushar

+0

嘗試在jquery-ui之前定義jquery –

+0

我已更新帖子,但它不起作用 –

回答

4
  1. 你需要下載jQuery的使用jQuery UI的或任何其他相關的插件
  2. 您使用jquery-ui-i18n其僅用於國際化。你需要包括jquery-ui主庫和如果你想使用國際化,在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>

+0

好點,但如果OP不包括jQuery UI,包括jquery-ui-i18n會拋出一個錯誤 –

+0

嘿@ A.Wolff在#2中提到_You需要包含jquery-ui主庫和if你想用i18n,在jquery-ui後包含它._ – Tushar

+0

它的工作原理,謝謝..但現在我動畫的圖像在動畫過程中移到頁面的左側,然後它回到中心..它可能是100%寬度的div的問題? –