you could this also do it this way:

<a href="full01.jpg" class="images"><img src="thumbnail01.jpg" alt="" /
></a>

$("a.images").click(function() {
     var large_img = $(this).attr('href');
     $("#mainImage").attr('src', large_img);
     return false;
});

this way it's more accessible for users without javascript


On 5 Apr., 12:49, "Oddish" <[EMAIL PROTECTED]> wrote:
> I've got a bunch of thumbnails, and when clicking these thumbnails, a
> larger image is supposed to change. I do this by changing the src
> attribute of the larger image, but I'm very new to jQuery so I was
> wondering about the best way to accomplish this. Right now, I've got
> this working code, but maybe it can be optimized?
>
> I wrap each thumbnail with a link:
>
> <a href="javascript:;" id="tnLink01"><img src="thumbnail01.jpg"
> alt="" /></a>
>
> This is the amateurish jQuery code I've conjured up:
>
> $("a#tnLink01").click(function() {
>     $("#mainImage").attr({src:"another_large_image.jpg"});
>
> });
>
> I'll need one of these functions for every thumbnail and that seems
> wrong somehow, so I'd really appreciate any helpfil tips and
> strategies for switching a larger image when clicking thumnails.

Reply via email to