Search code examples
jqueryrollover

Simple jquery image rollover


I have multiple thumbnails and want the main image to represent a large version of the thumbnail when each thumbnail is rolled over. I appreciate this must be a common usage, but I am struggling to find a simple solution. I have used the following code, which I appreciate may be poor, but this is all quite new for me.. thanks

$('.thumbnail').mouseover(function() {
    var currentimg = $('this').attr('src');
    $('#imageMain img').attr('src', currentimg);
});

I haven't included the HTML as I guess it's pretty clear what I am trying to achieve.


Solution

  • have you tried changing

    $('this').attr('src'); 
    

    with

    $(this).attr('src');
    

    ?