Toggle id

From Federal Burro of Information
Jump to navigationJump to search
function toggle(id) {
    if (document.getElementById) { // DOM3 = IE5, NS6
        if ( document.getElementById(id).style.display == 'block' ) {
            document.getElementById(id).style.display = 'none'
        } else {
            document.getElementById(id).style.display = 'block';
        }
    }
    else {
        if (document.layers) { // Netscape 4
            if ( document.id.display == 'block' ) {
                document.id.display = 'none';
            } else {
                document.id.display = 'block';
            }
        }
        else { // IE 4
            if ( document.all.id.style.display == 'block' ) {
                document.all.id.style.display = 'none';
            } else {
                document.all.id.style.display = 'block';
            }
        }
    }
}