私が知っている方法:
HTML:
<input type="button" id="msg" onclick="foo(this);" />
JS:
function foo(elementObj) { elementObj.toggle(); }
関数の引数として渡さずにelementObj
内部への参照を取得する方法はありますか?foo()
私がやりたい方法:
HTML:
<input type="button" id="msg" onclick="foo();" />
JS:
function foo() { elementObj = <any way I can get ref to html element here?>; elementObj.toggle(); }
PS
次のように関数を呼び出します。$("#msg").click(function(elementObj ) {elementObj.toggle();}
私が必要とするものではありません。