Root: WRM Database > Information Technology > Programming Languages > JavaScript > Showing and Hiding Divs > Showing a Div Using Javascript

Showing A Div Using JavaScript

Click the plus sign
This hides/shows your div

Here's how the code looks:

<div id="container">
<div id="top_div">Click the plus sign</div>
<a id="plus_minus_image" href="javascript:toggle('bottom_div', 'plus_minus_image');"><img src="../images/node_middle_plus.gif"></a>

<div id="bottom_div" style="display: block;">This hides/shows your div</div>

<script type = "text/javascript">
function toggle(showHideDiv, switchImgTag) {
var ele = document.getElementById(showHideDiv);
var imageEle = document.getElementById(switchImgTag);
if( == "block") { = "none";
imageEle.innerHTML = '<img src="../images/node_middle_plus.gif">';
else { = "block";
imageEle.innerHTML = '<img src="../images/node_middle_plus.gif">';