DOM Manipulation Examples

DOM Showing/Hiding

A big list of links in a web page might initially overwhelm a visitor. For a better UI (User Interface) experience, links may be hidden from view when the page loads. The click of a simple hyperlink reveals them at the visitor's discretion. Another click of the same hyperlink hides them again.

View source

function toggle( targetId ){
if (document.getElementById){
target = document.getElementById( targetId );
if (target.style.display == "none"){
target.style.display = "";
} else {
target.style.display = "none";
}
}
}

Show/Hide content