jquery 实现抖动效果

调用方法:$(“抖动元素”).shake(次数, 距离, 持续时间);

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;    
} 

来源:https://blog.csdn.net/nizhengjia888/article/details/73650478


210 Clicks !