您的位置:首页 - jQuery Plugins
jquery抖动插件keleyiShake

点击下面按钮查看效果:


以下是源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jquery抖动插件keleyiShake-柯乐义</title>
<script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
jQuery.fn.keleyiShake = function (intShakes /*Amount of shakes*/, intDistance /*Shake distance*/, intDuration /*Time duration*/) {
this.each(function () {
var jqNode = $(this);
jqNode.css({ position: 'relative' });
for (var x = 1; x <= intShakes; x++) {
jqNode.animate({ left: (intDistance * -1) }, (((intDuration / intShakes) / 4)))
.animate({ left: intDistance }, ((intDuration / intShakes) / 2))
.animate({ left: 0 }, (((intDuration / intShakes) / 4)));
}
});
return this;
}
</script>
<script type="text/javascript">
$(function () {
$('#keleyi').click(function () {
$(this).keleyiShake(2, 10, 400);
});
});
</script>
</head>
<body>
<input type="button" value="抖动" id="keleyi" />
</body>
</html>
本站导航
相关文章
柯乐义 Copyright© keleyi.com