Passing 'this' to an onclick event

azgaroth

New Member
Would this work\[code\]<script type="text/javascript">var foo = function(param){ param.innerHTML = "Not a button";};</script><button onclick="foo(this)" id="bar">Button</button>\[/code\]rather than this?\[code\]<script type="text/javascript">var foo = function(){ document.getElementId("bar").innerHTML = "Not a button";};</script><button onclick="foo()" id="bar">Button</button>\[/code\]And would the first method allow me to load the javascript from elsewhere to perform actions on any page element?
 
Back
Top