Jquery Plugin 初学

今天尝试写了一下Jquery Plugin,算是Jquery 面向对象的一种

 有几点心得

1. $.fn 的用法,类似prototype

2.this 必须赋值给局部变量

3. extend的用法

4.如何绑定事件的用法

$.fn.test = function (options) {
var settings = $.extend({
color: "dcdcdc",
url:"hello"

}, options);

var _oSelf = this;

this.click(function () {
alert(settings.color);
_oSelf.addClass("Green");
});

}

Always.Net
原文地址:https://www.cnblogs.com/alwaysdotnet/p/5341960.html