I have been trying to find a way to chain these methods together in a similar way to jQuery. here is an example of what I mean:
(function() {
window.foo = function foo( id ) {
if( window == this )
return new foo( document.getElementById( id ) );
this.alert = function() {
alert( object.value );
}
}
}());
foo('input').alert();
So as you can see, I would like to use the object that was passed into the class as part of the alert function, but I do not want to store it in the class via this.object = id, and then do alert( this.object.value );
What would be an elegant way to go about this?