ShowHide HTML Element

A simple function to hide and show an HTML tag.


The following snippet exemplifies the element to be show/hidden

<div id="myID" style="display: none;">
Item 1<br>
Item 2<br>
Item 3<br>

Below, a test link

<a href="#" onClick="showhide('myID')">
<img src="plus.png" border=0 id="myIDimg">ROOT

And finally, the javascript function

<script language="javascript" type="text/javascript"> 
function showhide(id){ 
    if (document.getElementById){ 
        obj = document.getElementById(id); 
        if ( == "none"){ 
   = ""; 
            eval(id + "img.src='minus.png'");
        } else { 
   = "none"; 
            eval(id + "img.src='plus.png'");
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License