0

当第三个 div 悬停在上面时,我正在尝试替换两个不同 div 的图像链接。我怎么能这样做,因为我的 jquery 不正确且不简洁。我确实意识到我不能把 this.attr 加倍,哈哈。任何帮助,将不胜感激。谢谢。

$('#minerallink').hover(function() { // On mouseenter
    $('#brainicon, #stomachicon').stop(true, true).fadeOut(function() { // Fade out the image, and when done
    $(this).attr('src', 'health-tips/images/images/medicineman-icons-dark_01.png', ).fadeIn();
    $(this).attr('src', 'health-tips/images/images/medicineman-icons-dark_04.png').fadeIn(); // Change its source and fade in
    });
    $('#manpic5').stop(true, true).fadeOut(function() { // Fade out the image, and when done
    $(this).attr('src', 'health-tips/images/images/medicineman-dark_05.png').fadeIn(); // Change its source and fade in
    });
 }, 
 function() { // On mouseleave - reverse the process
    $('#brainicon, #stomachicon').stop(true, true).fadeOut(function() {
        $(this).attr('src', 'health-tips/images/images/medicineman-icons_01.png').fadeIn();
        $(this).attr('src', 'health-tips/images/images/medicineman-icons_04.png').fadeIn();
         });
    $('#manpic5').stop(true, true).fadeOut(function() {
        $(this).attr('src', 'health-tips/images/images/medicineman_05.png').fadeIn();
    });
 });
4

1 回答 1

0

像这样拆分2个ID:

$('#stomachicon').stop(true, true).fadeOut(function() {
    $(this).attr('src', 'health-tips/images/images/medicineman-icons-dark_04.png').fadeIn();
});

$('#brainicon').stop(true, true).fadeOut(function() {
    $(this).attr('src', 'health-tips/images/images/medicineman-icons-dark_01.png', ).fadeIn();
});

其余的都这样做

于 2013-06-24T03:48:39.793 回答