/ Published in: JavaScript
Will toggle an element's style.visibility, or set it to visible/hidden as selected
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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"; } }