javascript-jquery插件

1.jquery创建插件

jQuery.extend({插件名:函数体,插件名:函数体});

html部分

<div id="div1">开始动画</div>

jquery部分

$(function(){
			$("#div1").click(function(){
				$(this).animate(
					{"left":800},
					6000,
					"easeOutBounce",
					function(){
						$(this).html("动画结束");
					}
					
				);
				
			});
		});

  插件部分

jQuery.extend(jQuery.easing, {
	easeOutBounce: function(x, t, b, c, d)
	{
		if ((t /= d) < (1 / 2.75))
		{
			return c * (7.5625 * t * t) + b;
		}
		else if (t < (2 / 2.75))
		{
			return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
		}
		else if (t < (2.5 / 2.75))
		{
			return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
		}
		else
		{
			return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
		}
	}
});

  

原文地址:https://www.cnblogs.com/yaxinwang/p/6430413.html