jquery - 悬停在另一个跨度上时如何显示下一个跨度文本

标签 jquery html css

<asp:UpdatePanel ID="pnlParent" runat="server" UpdateMode="Conditional" ClientIDMode="Static">
    <ContentTemplate>
        <div class="hidOverflow smallPad">
            <div class="setFloatL halfWidth vertAlignT">
                <span class="profileLabel">Contact Number:</span>
            </div>
            <div class="setFloatL vertAlignT">
                <asp:Label ID="lblCliDate" ClientIDMode="Static" runat="server" Text="" CssClass="profileLabelValue"></asp:Label>
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>


$(document).ready(function (e) {
    $("body").on("hover", ".profileLabel" , function () {
        alert($(this).next(".profileLabelValue").text());
    });
});

当鼠标悬停在 profileLabelspan 上时,我希望显示 profileLabelValuespan 的文本。使用我的代码,什么也没有发生。

我怎样才能做到这一点,因为我目前尝试的方法不起作用。

最佳答案

所以我不得不使用 mouseover 而不是 hover

我把代码改成了这样:

$(document).ready(function () {
    $("body").on("mouseover", ".profileLabel", function (e) {
        alert($(this).parent().next("div").find("span").first().text());
    });
});

以防将来有人需要它。

关于jquery - 悬停在另一个跨度上时如何显示下一个跨度文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29562290/

相关文章:

javascript - 如何从同一 html 页面上的多个按钮打开一个对话框

html - 将 HTML 链接到已删除的 CSS 文件的行为就像文件仍然存在一样

javascript - IE javascript 兼容性让我很苦恼

javascript - 从数据库中检索数据而不刷新页面

javascript - 删除父元素并重新 append 子元素

jquery - 如何创建一个在滚动时跟随并添加 Logo 的导航栏?

javascript - Angular Sortable 事件的工作方式与使用 JQuery 不同

html - <p> 在 div 的底部,没有空格

html - 无法使 Bootstrap 模板中的 CSS 边距消失

html - 环绕文本将图像向上推