最近再尝试写JQ的插件 查了看了好多插件 看到面向对象的写法 其中有 下面的实例:
;(function($, window, document,undefined) {
var abc = function(ele, opt) {
this.$element = ele,
this.defaults = {},
this.options = $.extend({}, this.defaults, opt)
}
abc.prototype = {
a: function() {
//代码a
},
b: function(){},
c: function(){}
}
$.fn.myPlugin = function(options) {
var abc1 = new abc(this, options);
//调用其方法
return abc1.a();
}
})(jQuery, window, document);
插件编写中 var abc1 = new abc(this, options); 中 this 指的是什么 ?是jq的DOM对象吗?
var abc = function(ele, opt) {
this.$element = ele,
this.defaults = {},
this.options = $.extend({}, this.defaults, opt)
}
中 this.$element = ele, 指的是传入绑定的jqDOM对象吗?
在写插件中 this.$element.[] 和 this.[] 有什么区别