Return to Snippet

Revision: 5035
at February 6, 2008 15:37 by martinkas


Initial Code
// show or hide a selected element
// if no state is given, the visibility is toggled
// otherwise visibility is set to hidden or visible as selected
function showHide(e, state) {
    el = document.getElementById(e);
    if (state == "hidden") {
    	el.style.visibility = "hidden";
    } else if (state == "visible") {
    	el.style.visibility = "visible";
    } else {
    	el.style.visibility = el.style.visibility  == "visible" ? "hidden" : "visible";
    } 
}

Initial URL

                                

Initial Description
Will toggle an element's style.visibility, or set it to visible/hidden as selected

Initial Title
Show/Hide Element

Initial Tags
css, html

Initial Language
JavaScript