Override jQuery functions
Posted
by
MotionGrafika
on Stack Overflow
See other posts from Stack Overflow
or by MotionGrafika
Published on 2010-12-27T05:35:16Z
Indexed on
2010/12/27
5:53 UTC
Read the original article
Hit count: 620
JavaScript
|jQuery
Is there way to override jQuery's core functions ? Say I wanted to add an alert(this.length) in size: function() Instead of adding it in the source
size: function() {
alert(this.length)
return this.length;
},
I was wondering if it would be possible to do something like this :
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());
}
© Stack Overflow or respective owner