NickMalloy
Programmer
I am looking for a good example of showing and hiding content within a <div> using css?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<style type="text/css">
#uniqueDiv1 {
display:none; /* use display:block; to show by default */
}
</style>
...
<body>
<a href="javascript:document.getElementById('uniqueDiv1').style.display = (document.getElementById('uniqueDiv1').style.display == 'block') ? 'none' : 'block';">Show/Hide Div</a>
<div id="uniqueDiv1">uniqueDiv1 content</div>
</body>
<script language="javascript">
function switchDisplay(obj) {
obj.style.display = (obj.style.display == "block") ? "none" : "block"
}
</script>
<input type="button" value="show/hide" onclick="switchDisplay(document.getElementById('mydiv'))">
<div id="mydiv" style="border:1px solid #000000; display:block">This is the div you want to hide</div>