« links for 2006-06-07 | Main | links for 2006-06-08 »

Explicitly Trigger A JavaScript Event Handler


<script type="text/javascript">
function foo(){ alert("Hello World") }
</script>
<div id="bar" onclick="foo();">click me to see an alert</div>
<div onclick = "document.getElementById('bar').onclick()" > click me to do the same thing </div>

This is trivial, but the subject came up at work today; and I wound up making a little demo, which I'll now post.

Explicitly Trigger An Event Handler in JavaScript