Nyusha Nyusha - 1 year ago 89
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 class="small-thumbs">
<div class="thumbs-container">
<div class="small-pre">
<a id="FindImage" href="#"><img id="ImageFound" src="image1.png"/></a>
<div class="small-pre">
<a id="FindImage" href="#"><img id="ImageFound" src="image2.png"/></a>

This is the JS part so far:

var bigthumb = $("#ImageFound").attr("src");

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

Answer Source
$(".small-pre img").click(function(e){    
          var smallSrc = $(this).attr("src");
          var bigSrc = "big-"+ smallSrc;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download