Tuesday 22 May 2007

toggle()

There are probably tons of toggle functions in use and i admit that this one is nothing special but it is very handy for me. The history of ‘toggling’ basically comes down to showing and hiding off elements upon an event being fired. Here is my version of it


function toggle(objId) {
var el = document.getElementById(objId);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}

No comments: