Dynamically set onClick events in IE and Firefox

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(); };

No Comments

You can leave the first : )

Leave a Reply