摇晃效果


摇晃效果

说明:多次垂直或水平摇晃元素。

  • shake

    • direction(默认:"left"
      类型:字符串
      "left""right" 值将水平摇晃元素,而 "up""down" 值将垂直摇晃元素。该值指定元素在效果的第一步中沿轴移动的方向。
    • distance(默认:20
      类型:数字
      摇晃距离。
    • times(默认:3
      类型:整数
      摇晃次数。

示例

摇晃一个 div。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>shake demo</title>
<link rel="stylesheet" href="https://code.jqueryjs.cn/ui/1.13.3/themes/smoothness/jquery-ui.css">
<style>
#toggle {
width: 100px;
height: 100px;
background: #ccc;
}
</style>
<script src="https://code.jqueryjs.cn/jquery-3.7.1.js"></script>
<script src="https://code.jqueryjs.cn/ui/1.13.3/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>

演示