Nyusha Nyusha - 6 months ago 12
Javascript Question

Select diferent pictures in jquery/js

i'm trying to make a simple photo viewer, and i want to know how to select the src of that image, in order to change the big image (.big-t)
This is the HTML code:



<div class="diaporama-thumbs" id="wabi3-slider">
<div class="thumb-preview">
<img id="big-thumb" class="big-t" src="big-image1.png" />
</div>
<div class="small-thumbs">
<div class="thumbs-container">
<div class="small-pre">
<a id="FindImage" href="#"><img id="ImageFound" src="image1.png"/></a>
</div>
<div class="small-pre">
<a id="FindImage" href="#"><img id="ImageFound" src="image2.png"/></a>
</div>
</div>
</div>
</di>




This is the JS part so far:


$("#ImageFound").click(function(e){
var bigthumb = $("#ImageFound").attr("src");
alert(bigthumb);
});




The alert(bigthumb) only return "image1" even if i click on the second small image
I hope you can understand me, Ragards!

Answer
$(".small-pre img").click(function(e){    
          var smallSrc = $(this).attr("src");
          var bigSrc = "big-"+ smallSrc;
          alert(bigSrc);
});