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.