Change 'img src' and 'a href' on click

Change 'img src' and 'a href' on click

Hi all,

I have a simple image gallery consisting of an image with smaller thumbnails below that change on click which works fine.
I now decided to change a link along with the gallery image source on click, but can't really get it working.

Here is my code to swap the image to the clicked thumbnail image:
  1. jQuery("ul.thumb li a").click(function() {
            var mainImage = jQuery(this).attr("href");
            jQuery("#main_view img").attr({ src: mainImage });
            jQuery("#main_view a").attr({  href: mainImage });  // This is the line that isn't working!
            return false;       
        });




What am I doing wrong?