OK guys. I want a larger displayed image to switch when a user clicks on a smaller thumbnail image.
This is my jquery script but so far it doesn't switch. Nothing happens when the thumbnail is clicked.
Its strange because I have two arrow images that slide the thumbsnails across when clicked but for some reason not when the acutal thumb is clicked. What on earth is going on?
JQuery:
$(document).ready(function () {
// when image with ID thumb is clicked change src
$("img#thumb").click(function () {
var imgpath = $(this).attr("src");
$("img#cover").attr("src", imgpath);
});
// slide more thumbnails
$("#arrowright").click(function () {
$("#innerthumb").animate({ marginLeft: "-850px" });
});
$("#arrowleft").click(function () {
$("#innerthumb").animate({ marginLeft: "0px" });
});
// image change on click
$("img#thumb").click(function () {
var newimg = $(this).attr("src");
$("img#cover").attr("src", newimg);
});
HTML
<div id="mainimage">
<div id="inner">
<img id="cover" src="images/environments/img0.jpg" width="980px" />
<img id="cover-old" src="" width="980px"/>
</div>
</div> <!--end of mainimage div-->
<div id="arrowleft"><img src="images/arrowleft.png"></div>
<div id="innerthumb">
<div id="thumb1" ><img id="thumb" src="images/environments/img0.jpg" width="160px" height="80px"/></div>
<div id="thumb2" ><img id="thumb" src="images/environments/img1.jpg" width="160px" height="80px" /></div>
<div id="thumb3" ><img id="thumb" src="images/environments/img2.jpg" width="160px" height="80px" /></div>
<div id="innerthumb"></div>
<div id="arrowright"><img src="images/arrowright.png"></div>