Example of (how I would) overload a function: jQuery.extend({ _trim: jQuery.trim, trim: function(s) { // do something to s first, then you might want to call original function this._trim.call(this, s); } });
Though if you're thinking of overloading functions like trim, wouldn't it be better to extend the String object? String.prototype.trim = function() { return this.toString().replace(/^\s+|\s+$/g, ""); }; The example is an unmodified trim from jQuery - but it's the kind of thing you may want to reuse even when you don't require jQuery. On Apr 23, 4:22 am, "howard chen" <[EMAIL PROTECTED]> wrote: > I want to overload some core jQuery method, e.g. trim() method > > any codes sample or recommendation to do this? > > thanks.