當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JQuery UI Shake效果用法及代碼示例

Shake Effect

說明:多次垂直或水平搖動元素。

  • shake
    • direction(默認:"left")
      類型:String
      "left""right" 的值將水平搖動元素,而 "up""down" 的值將垂直搖動元素。該值指定元素應在效果的第一步沿軸移動的方向。
    • distance(默認:20)
      類型:Number
      搖晃的距離。
    • times(默認:3)
      類型:Integer
      時代動搖。

例子:

搖一個div。

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>shake demo</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
  <style>
  #toggle {
    width: 100px;
    height: 100px;
    background: #ccc;
  }
  </style>
  <script src="//code.jquery.com/jquery-1.12.4.js"></script>
  <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
 
<p>Click anywhere to shake the box.</p>
<div id="toggle"></div>
 
<script>
$( document ).click(function() {
  $( "#toggle" ).effect( "shake" );
});
</script>
 
</body>
</html>

演示:

相關用法


注:本文由純淨天空篩選整理自jqueryui.com大神的英文原創作品 Shake效果。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。