Forum Moderators: open

Message Too Old, No Replies

Show/hide/swapping

Swapping divs

         

Izkoo

8:51 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



Hi there, I was wondering if you guys could help me with a js here.

You see, I wan't to have an image with the text "show". When pressing this image, it will disappear, and another div appears. Inside this div, I wan't to have a image with the text "hide", which will hide the div, and show the "show" image.

I was also wondering about how to show/hide/swap two divs. F.i:
<a href="XX"><img /></a> /// by clicking this, the script should hide this image/link and show div1 and div2

<div id="1">
XX
</div>

<p>XX</p>

<div id=2">
XX
</div>

(If this is impossible or too hard, I would really wan't a script that shows div(s) with class="XX")

webfoo

8:41 pm on Jun 7, 2008 (gmt 0)

10+ Year Member



Try this:

<script language="JavaScript">
function show(what) {
document.getElementById("xx").style.display='none';
document.getElementById("yy").style.display='none';
document.getElementById(what).style.display='block';
}
</script>

<div id="xx" style="display: block;" onClick="show('yy');">This is XX. Click for YY</div>

<div id="yy" style="display: none;" onClick="show('xx');">This is YY. Click for XX</div>

--webfoo

webfoo

10:36 pm on Jun 11, 2008 (gmt 0)

10+ Year Member



Did this help? I just want to make sure all our customers are satisfied !