I'm wondering how to change what function is called when an onClick event is fired. I've got a link that, when clicked, calls displayChildren(). I want displayChildren to change what function is called when the link is clicked again, to hideChildren().
I've tried:
Code: Select all
document.getElementById(p_id).childNodes[0].onclick = 'function onclick(event){hide_children("' + p_id + '");}';Code: Select all
document.getElementById(p_id).childNodes[0].onclick = 'hide_children();';Any ideas?
[Update: I've changed my approach to create a function toggleChildrenDisplay and make that function determine what to do. I still haven't found any way to update the onClick event. If you know how to do it though, leave your solution for posterity - others might still benefit]