Forum Moderators: open

Message Too Old, No Replies

Show / Hide Image

         

tekn0phile

2:43 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



How can I show/hide an image in a page?
I want a show link that would reveal the hidden
image

Thanks

Rambo Tribble

2:54 pm on Oct 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two possibilities exist, the CSS properties of display:none/block/inline/etc.; or visibility:hidden/visible/etc. Either is manipulable by JavaScript and is usually implemented using element ids, as in:

document.getElementById("elementId").style.visibility="visible";

The choice of technique is application dependent.

DrDoc

2:57 pm on Oct 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld! [WebmasterWorld.com]

What you need to do is simply toggle the property used to hide the element.
For example, if you're using

visibility:hidden
you need to toggle between
hidden
and
visible
, which can be set in this manner:

document.getElementById('the_ID_of_your_image').style.visibility = "...";

Now, if you're using

display:none
, you need to toggle between
none
and
inline
:

document.getElementById('the_ID_of_your_image').style.display = "...";

<added>So, what Rambo Tribble said, since he beat me to it ;)</added>

tekn0phile

3:00 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



I 'll try them both.

Tnx