iamcam

Dynamically set onClick events in IE and Firefox

February 11, 2008 · Leave a Comment

I’ve had a couple of small tasks where I’ve needed to toggle the onclick events on a page element. It was surprising how difficult it is to get a straight answer on how to do this.


function hide_field() {
my_element.onclick = function() { show_field(); };
}
function show_field() {
my_element.onclick = function() { hide_field(); };
}

Categories: Javascript

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment