如题,为什么要这么做呢?为了配合上面的语句,还得加上下面这句很绕的语句:
jQuery.fn.init.prototype = jQuery.fn;
为什么不能这么干呢?
(function(){
var jQuery = function(){
return new F();
};
var F = function(){
return this;
};
F.fn = F.prototype = {
jquery : 1.0,
test : function(){
console.log('test');
return this;
}
};
jQuery.fn = jQuery.prototype = F.prototype;
window.jQuery = window.$ = jQuery;
})();
var a = $('body').test('li');
console.log('');
$.fn.extend = function(){console.log('extended');}
a.extend();
这样层次清晰,而且兼顾到插件扩展,求大神赐教。