您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jQuery通过扩展实现抖动效果的方法_jquery

2024/4/13 14:38:37发布13次查看
本文实例讲述了jquery通过扩展实现抖动效果的方法。分享给大家供大家参考。具体实现方法如下:
1. javascript代码如下:
复制代码 代码如下:
jquery.fn.shake = 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            jqnode.animate({ left: (intdistance * -1) },(((intduration / intshakes) / 4)))
            .animate({ left: intdistance },((intduration/intshakes)/2))
            .animate({ left: 0 },(((intduration/intshakes)/4)));
        }
    });
    return this;
}
2. 使用方法如下:
复制代码 代码如下:
$(function() {
  $('#btn').click(function() {
    $(this).shake(2,10,400);
  });
});
希望本文所述对大家的jquery程序设计有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product