jasonmwhitaker
11-08-2011, 07:11 PM
Hello, all. I have a common problem, but despite my research I have been unable to find a solution that works for my situation.
I have a large image and several thumbnails below it. I am working with a content management system, so I am able to edit the output of the anchor text around the image, the divs around the image, but NOT the actual image string itself.
The images do have some classes built into them, but no IDs.
Anyways, I want the main image source to change based on the href of the thumbnail below. So if you click on any one of the thumbs, the href for that thumbnail populates as the source for the main image.
Here is my code so far:
<div class="images" id="big-image">
<a href="dianaminiflash_shop0001-11.jpg">
<img width="500" height="500" src="dianaminiflash_shop0001-11-500x500.jpg" class="attachment-shop_single wp-post-image" /></a>
<div class="thumbnails">
<a href="dianamini_en-rose_front1.jpg" title="dianamini_en-rose_front" rel="thumbnails" class="product-thumb first">
<img src="dianamini_en-rose_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a>
<a href="diana-mini_fern-green_front1.jpg" class="product-thumb ">
<imgsrc="diana-mini_fern-green_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a>
<a href="diana-mini_flashkit_white_front1.jpg" class="product-thumb last">
<img src="diana-mini_flashkit_white_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a>
</div>
</div>
One of the things I've tried that has not worked but has been offered up as a solution on this forum and others is:
$(".thumbnails a").click( function() {
var changeSrc = $(this).attr("href");
$(".attachment-shop_single").attr("src", changeSrc);
return false;
});
Any suggestions on what I'm doing wrong here? I really appreciate the help in advance.
I have a large image and several thumbnails below it. I am working with a content management system, so I am able to edit the output of the anchor text around the image, the divs around the image, but NOT the actual image string itself.
The images do have some classes built into them, but no IDs.
Anyways, I want the main image source to change based on the href of the thumbnail below. So if you click on any one of the thumbs, the href for that thumbnail populates as the source for the main image.
Here is my code so far:
<div class="images" id="big-image">
<a href="dianaminiflash_shop0001-11.jpg">
<img width="500" height="500" src="dianaminiflash_shop0001-11-500x500.jpg" class="attachment-shop_single wp-post-image" /></a>
<div class="thumbnails">
<a href="dianamini_en-rose_front1.jpg" title="dianamini_en-rose_front" rel="thumbnails" class="product-thumb first">
<img src="dianamini_en-rose_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a>
<a href="diana-mini_fern-green_front1.jpg" class="product-thumb ">
<imgsrc="diana-mini_fern-green_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a>
<a href="diana-mini_flashkit_white_front1.jpg" class="product-thumb last">
<img src="diana-mini_flashkit_white_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a>
</div>
</div>
One of the things I've tried that has not worked but has been offered up as a solution on this forum and others is:
$(".thumbnails a").click( function() {
var changeSrc = $(this).attr("href");
$(".attachment-shop_single").attr("src", changeSrc);
return false;
});
Any suggestions on what I'm doing wrong here? I really appreciate the help in advance.