jQuery爆炸效果不起作用

时间:2014-06-06 10:21:10

标签: 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>

2 个答案:

答案 0 :(得分: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>

答案 1 :(得分: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

相关问题