使用jQuery进行悬停在文本上的切换

making hover over text toggle with jQuery

本文关键字:文本 jQuery 悬停 使用      更新时间:2023-09-26

当光标悬停时,我试图使作为元素属性的一些文本向上切换。目前,我看到这个代码发生了一些奇怪的事情,但我觉得我很接近。。。有什么想法吗?

$(".hoverDes").mousemove(function(){
    $(".hoverDes").toggle(function(e){
        var hoverIt = $(this).attr("hoverDesDiv");
        $("#hoverDiv").text(hoverIt).show();
        $("#hoverDiv").css("top", e.clientY-30).css("left", e.clientX-50);
    }).mouseout(function(){
        $("#hoverDiv").hide();
    })
});

你的问题我还不够清楚,但从你上面的代码来看,我想你需要这个

$(".hoverDes").hover(function(e){
    var hoverIt = $(this).attr("hoverDesDiv");
    $("#hoverDiv").text(hoverIt).show('slow');  
},
function(e){
    $("#hoverDiv").hide('slow');
});

这样的东西?

  hoverIt.show('slide', {direction: 'right'}, 500);