我正在尝试制作一个jQuery的补充库,但不是jQuery插件,也不是jQuery扩展:
第一个功能:
function w(id) {
return $(id);
}
它可以作为jQuery插件:
$.prototype.test = function(){
console.log("testing");
}
w("div").test(); // test
我想要的是这个,作为w()的原型函数,但不起作用:
w.prototype.test = function(){
console.log("testing");
}
w("div").test(); // test
谢谢,
它适用于:
w.prototype = jQuery.prototype;
谢谢SLaks!
但当它真的起作用时,就不起作用了:
w.prototype = {
test: function(){
console.log("testing");
}}
现在它起作用了;
function w(id) {
return $(id);
}
w.prototype = jQuery.prototype;
w.prototype.extend({
test:function(){
console.log("testing");
}
});
谢谢你的帮助!!!
您想要
w.prototype = jQuery.prototype;