Posts

Showing posts with the label show/hide content

Show/Hide or Toggle Content with Javascript

Here is a simple javascript snippet that you can use to toggle the contents of a div. function toggleDisplay() {     var e = document.getElementById('toggle_div');     e.style.display = (e.style.display == 'none') ? 'block' : 'none';  } <input type="button" value="Toggle Display" onclick="toggleDisplay()" /> <div id="toggle_div" style="display: none"> Hello World. </div>