2014-06-06 79 views
0

我使用下面的代碼,但什麼也沒發生......jQuery的爆炸效果不工作

$(document).ready(function(){ 
    $("#btn4").click(function(){ 
     $(".shake").show("explode", { pieces: 16 }, 2000); 
    }); 
}); 
.shake { 
    height: 100px; 
    width: 100px; 
    background: #666; 
    margin: 20px; 
} 
<button id="btn4">Shake</button> 
<div class="shake"></div> 
+3

' 「爆炸」'是不是一個有效的參數爲'秀'在jQuery的核心()答案。你有沒有包含jQuery UI? –

+0

是的,包括jquery UI .. – user3714631

+0

你應該使用.toggle而不是.show –

回答

0

沒有包含的是庫。你的代碼應該是這樣的。

<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <title>explode demo</title> 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> 
    <style> 
    #toggle { 
    width: 100px; 
    height: 100px; 
    background: #ccc; 
    } 
    </style> 
    <script src="//code.jquery.com/jquery-1.10.2.js"></script> 
    <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> 
</head> 
<body> 

<div><input type"button" id="toggle"></div> 

<script> 
$(document).click(function() { 
    $("#toggle").toggle("explode"); 
}); 
</script> 

</body> 

爲您的代碼我包括以下

your code answer

1
<script src="//code.jquery.com/jquery-1.10.2.js"></script> 
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> 
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> 
<script> 
$(document).click(function() { 
$(".shake").toggle("explode"); 
}); 
</script>