Change the image source on rollover using jQuery

前端 未结 14 1278
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 10:23

I have a few images and their rollover images. Using jQuery, I want to show/hide the rollover image when the onmousemove/onmouseout event happen. All my image names follow t

14条回答
  •  鱼传尺愫
    2020-11-22 11:02

    Adapted from Richard Ayotte's code - To target an img in a ul/li list (found via wrapper div class here), something like this:

    $('div.navlist li').bind('mouseenter mouseleave', function() {    
        $(this).find('img').attr({ src: $(this).find('img').attr('data-alt-src'), 
        'data-alt-src':$(this).find('img').attr('src') }
    ); 
    

提交回复
热议问题