jQuery通过扩展实现抖动效果的方法
2015-03-11 00:00
2251 查看
本文实例讲述了jQuery通过扩展实现抖动效果的方法。分享给大家供大家参考。具体实现方法如下:
1. JavaScript代码如下:
2. 使用方法如下:
希望本文所述对大家的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<=intShakes; 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程序设计有所帮助。
相关文章推荐
- jQuery通过扩展实现抖动效果的方法
- jquery果冻抖动效果实现方法
- jquery通过扩展select控件实现支持enter或focus选择的方法
- jquery通过扩展select控件实现支持enter或focus选择的方法
- 通过jquery选择li菜单实现无刷新css效果
- ASP.NET jQuery 实例9 通过控件hyperlink实现返回顶部效果
- 博客侧边栏模块跟随滚动条滑动固定效果的实现方法(js+jquery等)
- 通过jQuery来实现页脚永远固定在页面底部的效果
- 通过JQuery实现win8一样酷炫的动态磁贴效果
- 表格的头部固定效果通过css及jquery分别实现
- jquery的index方法实现tab效果
- jquery图片延迟加载效果实现方法
- 通过jquery还原含有rowspan、colspan的table的实现方法
- 通过jquery实现tab标签浏览效果
- 通过javascript直接实现jQuery的$(".class1")方法
- ASP.NET jQuery 食谱9 (通过控件hyperlink实现返回顶部效果)
- 用 jQuery 实现页面滚动(Scroll)效果的完美方法
- 两种方法使用jquery实现左右移动效果(包含each遍历方式)
- 通过JQuery实现win8一样酷炫的动态磁贴效果(示例代码)