Shake效果可与Effect()方法一起使用。这将多次垂直或水平地摇动元素。
selector.effect( "shake", {arguments}, speed );
下面是对所有参数-的描述
times - 摇晃时间。默认值为3。
distance - 摇晃距离。默认值为20。
direction - 摇晃方向,可以是 "up", "down", "left", "right". 默认为"left"
下面是一个简单的示例,显示了此效果-的用法
链接:https://www.learnfk.comhttps://www.learnfk.com/jquery/effect-shake.html
来源:LearnFk无涯教程网
<html> <head> <title>The jQuery Example</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"> </script> <script type="text/javascript" language="javascript"> $(document).ready(function() { $("#button").click(function(){ $(".target").effect( "shake", {times:4}, 1000 ); }); }); </script> <style> p {background-color:#bca; width:200px; border:1px solid green;} div{ width:100px; height:100px; background:red;} </style> </head> <body> <p>Click the button</p> <button id="button"> Shake </button> <div class="target"> </div> </body> </html>
这将产生以下输出-
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)