javascript hide/unhide, but want an arrow to point down/up on hide/unhide

Posted by user1305810 on Stack Overflow See other posts from Stack Overflow or by user1305810
Published on 2012-07-09T02:32:03Z Indexed on 2012/07/10 3:16 UTC
Read the original article Hit count: 443

Filed under:

I have a simple hide/unhide div section using simple JavaScript. I need to have an arrow image, which will toggle the content visibility when clicked, and I want the little arrow to toggle between right/down positions when the content is hidden and unhidden.

HTML content:

<a href="javascript:showOrHide();"><img src="Image_Files/Copyright.png" alt="BioProtege Inc" border="0" /></a> 
<img src="Image_Files/Copyright_Arrow_Hidden.png" alt="Arrow" border="0" />

<div id="showorhide">
Copyright 2012+ BioProtege-Inc.Net | LG Fresh Designz
<br />
Contact Us @ [email protected]
</div>

JavaScript content:

function showOrHide() 
{
    var div = document.getElementById("showorhide");
    if (div.style.display == "block") 
    {
        div.style.display = "none";
    }
    else 
    {
        div.style.display = "block";
    }
}

© Stack Overflow or respective owner

Related posts about JavaScript