JQUERY鼠标移动显示相应内容

HTML代码:<em class="same-name"> <i><img src="鼠标移动到这张图片显示span内容.jpg" /></i> <span><img src="小图标3.jpg" />我是显示内容1</span> </em><em class="same-name"> <i><img src="鼠标移动到这张图片显示span内容.jpg" /></i> <span><img src="小图标3.jpg" />我是显示内容2</span> </em><em class="same-name"> <i><img src="鼠标移动到这张图片显示span内容.jpg" /></i> <span><img src="小图标3.jpg" />我是显示内容3</span> </em>鼠标移动到指定标签 <i> 里的图片上,显示相应 <span> 里的内容,当相应 <span> 显示后鼠标移动到 <span> 标签上一样显示不会消失,移开隐藏。请问如何用JQUERY实现,求解,先谢谢啦!~
2026年09月20日 23:09
有2个网友回答
网友(1):

我猜会继续提问


    var t;
    $('.same-name span').animate({top: "0px", opacity: "0"});
    $('.same-name i img').hover(function(){
            //ImgToggle($(this),true);
            $(this).parent().parent().children("span").stop().animate({top: "-16px", opacity: "1"})
        },function(){
            t=setTimeout("ImgToggle("+$(this).parent().parent().index()+")",400);
            console.log($(this).parent().parent().index());
        }
    )
    $('.same-name span').hover(function(){clearTimeout(t)},function(){
        $(this).stop().animate({top: "0px", opacity: "0"});
    })
    function ImgToggle(i){
        $('.same-name').parent().children().eq(i).find('span').animate({top: "0px", opacity: "0"});
    } 

网友(2):








我是显示内容1