jquery function call from html without passing this

jpoplive

New Member
The way I know:HTML: \[code\]<input type="button" id="msg" onclick="foo(this);" />\[/code\]JS: \[code\]funtion foo(elementObj) { elementObj.toggle(); }\[/code\]Is there any way to get reference to \[code\]elementObj\[/code\] inside \[code\]foo()\[/code\] without passing it as function argument?How I want to do:HTML: \[code\]<input type="button" id="msg" onclick="foo();" />\[/code\]JS: \[code\]funtion foo() { elementObj = <any way I can get ref to html element here?>; elementObj.toggle(); }\[/code\]P.S.Call function like this: \[code\]$("#msg").click(function(elementObj ) {elementObj.toggle();}\[/code\]Is not what I need.
 
Back
Top