//抖动效果
//intShakes:抖动次数;intDistance:抖动左右距离;intDuration:持续时间
jQuery.fn.shake = function (intShakes, intDistance, intDuration) {
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;
}
使用:
$('#tishi').shake(3, 20, 400);