jquery shake button

Original link: http://www.cnblogs.com/q460021417/p/4548618.html

http://runjs.cn/detail/tyx8dbag

 

// shakenum: jitter times, shakeDistance: jitter distance 
jQuery.fn.Shake = function {(shakenum, shakeDistance)
     the this .each ( function () {
         var jSelf = $ ( the 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);
    });
});

 

Reproduced in: https: //www.cnblogs.com/q460021417/p/4548618.html

Guess you like

Origin blog.csdn.net/weixin_30814319/article/details/94785771