I am trying to find a way to combine these methods together similarly 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 to the class as part of the warning 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 do this?
source share