悬停功能为警报工作,但不能附加span标签

Hover functionality working for alert but not able to append the span tag

本文关键字:但不能 span 标签 工作 功能 悬停      更新时间:2023-09-26

悬停功能可用于显示警报,但是我不能用span标签显示附加的文本我不知道这是怎么回事。下面提供我的代码:

$('document').ready(function () {
    window.setTimeout(function () {
        $('.cubeCell').each(function () {
            var htmlText = $(this).attr('data-text');
            $(this).append('<div class="cubeTextStyle">' + htmlText + '</div>');
            $(this).hover(
            function () {
                //alert("123");
                $(this).append($("<span> ***</span>"));
            },
            function () {
                $(this).find("span:last").remove();
            });
        });
    }, 600);
});

<div class="cubeCell"
     data-text="hover here"
     class="desktopContactImage cubeCell"
     data-caption="&lt;a style='padding-left: 40px; font-size: 14px; color: grey;' href='/Inventory/Partnumber/?ps=list' &gt;Register&lt;/a&gt; &lt;div&gt; &lt;a style='padding-left: 40px; font-size: 14px; color: grey;' href='/Bom/Bom/?ps=list' &gt;Demo&lt;/a&gt; &lt;/div&gt; &lt;a style='padding-left: 40px; font-size: 14px; color: grey;' &gt;Reports&lt;/a&gt;"
     data-image="http://intra.defie.co/images/Desktop_icons_02.07.13/guest.png"
></div>

我对标记不太了解也不知道你是如何实现旋转框的但我想知道你是否想在cubeStyleText旁边显示文本因为你在悬停时将span添加到同一位置但它显示在框的后面如果是这样的话,而不是

$(this).append($("<span> ***</span>"));

使用这个

$(this).children(".cubeTextStyle").append($("<span> ***</span>"));

这似乎解决了定位问题,如果它是。

相关文章: