Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swapping script

Status
Not open for further replies.

Izkoo

Technical User
Jun 6, 2008
1
NO
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:
Code:
<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")
 
Will look something like this:
Code:
<div>
	<div id="show" onclick="this.style.display='none';this.parentNode.childNodes[1].style.display='inline'">show</div>
	<div id="hide" onclick="this.style.display='none';this.parentNode.childNodes[0].style.display='inline'">show</div>
</div>

you can put it in a function too:
onclick="my_image_swapping_function(this)"



Greetings, Harm Meijer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top