change the image doesnt work

here is my javasript:

$(function() {
    $(".image2").click(function() {
        var image = $(this).attr("rel");
        $('#random_img').hide();
        $('#random_img').fadeIn('slow');
        $('#random_img').attr('src') == image;
        var image2 = $('#random_img').attr('src');
        $("#thumb2 a img").removeClass("open");
        $("#thumb2 a[rel='" + image2 + "'] img").addClass("open");
        return false;
    });
});

here is my html:

<div id="image2">
    <img id="random_img" src="/documents/templates/projedepo/banner/indigovision.jpg" height="420" width="964" />
</div>
<div id="thumb2">
    <a href="#"  class="image2">
        <img title="Canon" class="slider_thumb" src="/documents/templates/bilgiteknolojileri/images/t_flash/t1.png" border="0"/></a>
    <a href="#"  class="image2">
        <img title="IndigoVision" class="slider_thumb" src="/documents/templates/bilgiteknolojileri/images/t_flash/t2.png" border="0"/>
    </a>
</div>

when i click on a thumbnail, the animation fadeIn and hide works, but the image is not changed...why?

Thank u @Shurdoof! now everything works fine! here is the solution:

$('#random_img').attr('src',image);

To change the image, specify second argument toattr:

$('#random_img').attr('src', image);

Instead of this which won't work:

$('#random_img').attr('src') = image;

Check out the second version ofattrhere for more info.


You are also not storingsrcin yourimagevariable but itsrelattribute here:

var image = $(this).attr("rel");

Which should be:

var image = $(this).attr("src");

Checkhttp://api.jquery.com/attr/

Also, you are using equality operator==where you may usually use assignment operator=. This won't work with.attrmethod though..

$('#random_img').attr('src') == image;

should be

$('#random_img').attr('src') = image;