0

I have a jquery scroller i made with thumbnails and I am trying to create a mini script.

When a user clicks on the thumb nail, it updates code like this:

<div id="big_image">
    <img src="HERE.jpg" alt="my image"/>
</div

So when you click a thumbnail on the scroller it updates the SRC of the IMG tag on the page? Any ideas how I can get started?

0

3 Answers 3

2
$('#scroller img').click(function() {
    $('#big_image img').attr('src', whatever_full_size_image_src_is_for(this));
}
Sign up to request clarification or add additional context in comments.

2 Comments

The difference between this answer and my answer is actually ">" character in the selector. > means select this direct children instead of all the descendants which means in my example only child imgs will be selected rather than all of descendants.
While that is true, Aaron, I don't suspect #big_picture to hold more than a single IMG as its child, based on the ID being singular.
1
// Replace larger image with src of whatever thumbnail you clicked
$("img.myImage").click(function(){
  $("img.bigImage").attr("src", $(this).attr("src"));
});

Note, unless you're crushing large images into thumbnail sizes, this won't be a very elegant solution to your problem. And in all honesty, if you are crushing large images into thumbnail sizes, that also isn't a very good solution.

1 Comment

What do you recomend if i want to say add some text to the full size image meaning image-name-full.jpg, to show the large images, then have thumbnails.
0
 function updateImage()
 { 
   $("#big_image > img").attr("src","imagePath"); 
 }

you can use this function in thumbnail onclick event.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.