The following code will toggle the display (show/hide) of a division in both IE 5.5+ and Mozilla Firefox and can be used for menus, TOC’s etc. This is simple, but useful. If your looking for a really good collection of cross browser Javascript functions for manipulating HTML and the DOM then check out prototype and if you want a really good overview of the Javascript language, along with some good stories and history of the language, you must see these videos from Dougles Crockford .
function td(d)
{
if(document.getElementById) {
var o = document.getElementById(d) ;
if((o.style.display == "block") || (o.style.display == ""))
o.style.display = "none" ;
else
o.style.display = "block" ;
}
}
Advertisements