有没有办法覆盖jQuery的核心函数?
比如我想在size: function()中添加alert(this.length),而不是在源代码中添加。
size: function() {
alert(this.length)
return this.length;
},
我想知道是否可能做到这样:
if (console)
{
console.log("Size of div = " + $("div").size());
var oSize = jQuery.fn.size;
jQuery.fn.size = function()
{
alert(this.length);
// Now go back to jQuery's original size()
return oSize(this);
}
console.log("Size of div = " + $("div").size());
}