jquery抖动的按钮

http://runjs.cn/detail/tyx8dbag

 

//shakenum:抖动的次数,shakeDistance:抖动的距离
jQuery.fn.Shake = function (shakenum , shakeDistance) {
    this.each(function () {
        var jSelf = $(this);
        jSelf.css({ position: 'relative' });
        for (var x = 1; x <= shakenum; x++) {
            jSelf.animate({ left: (-shakeDistance) }, 50)
                .animate({ left: shakeDistance }, 50)
                    .animate({ left: 0 }, 50);
            }
        });
        return this;
    }
        
    
$(function () {
    $('#btn').click(function () {
        $(this).Shake(2, 10);
    });
});

 

posted @ 2015-06-03 11:12  Xpress  阅读(415)  评论(0编辑  收藏  举报