jQuery - Show id, based on selected items class?
Posted
by Jon Hadley
on Stack Overflow
See other posts from Stack Overflow
or by Jon Hadley
Published on 2010-05-27T20:47:46Z
Indexed on
2010/05/27
21:21 UTC
Read the original article
Hit count: 155
jQuery
I have a layout roughly as follows:
<div id="foo">
<!-- a bunch of content -->
</div>
<div id="thumbnails">
<div class="thumb-content1"></div>
<div class="thumb-content2"></div>
<div class="thumb-content3"></div>
</div>
<div id="content-1">
<!-- some text and pictures, including large-pic1 -->
</div>
<div id="content-2">
<!-- some text and pictures, including large-pic2 -->
</div>
<div id="content-3">
<!-- some text and pictures, including large-pic3 -->
</div>
etc ....
On page load I want to show 'foo' and 'thumbnails' and hide the three content divs.
As the user clicks each thumbnail, I want to hide foo, and replace it with the matching 'content-x'.
I can get my head round jQuery show, hide and replace (although, bonus points if you want to include that in your example!). But how would I extract and construct the appropriate content id, from the thumbnail class, then pass it to the show hide code?
© Stack Overflow or respective owner