Fandom

Scratchpad

Javascript: context of this

219,512pages on
this wiki
Add New Page
Discuss this page0 Share
<script language="JavaScript" type="text/javascript">
var var_onclick = new Function("f(this);");
function f_onclick() { f(this); }
function f(node) {
   var debug = document.getElementById("debug");
   debug.value += node+"\n";
   debug.value += ", "+node.innerHTML+"\n";
}
</script>
<span onclick='f(this);' >span</span>
<button onclick='f(this);' >a</button>
<span onclick='var_onclick();' >span</span>
<button onclick='var_onclick();' >a</button>
<span onclick='f_onclick();' >span</span>
<button onclick='f_onclick();' >a</button>
<textarea id=debug rows=12 cols=100 >
</textarea>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random wikia