<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());
});
});当profileLabelValue类span徘徊在profileLabel类span上时,我希望展示它的文本。用我的代码什么都没发生。
我如何才能做到这一点,因为我目前正在尝试的方法不起作用。
发布于 2015-04-10 13:11:39
因此,我不得不使用hover而不是mouseover。
我将代码更改为:
$(document).ready(function () {
$("body").on("mouseover", ".profileLabel", function (e) {
alert($(this).parent().next("div").find("span").first().text());
});
});以防将来有人需要它。
发布于 2015-04-10 13:11:55
你应该这样做:-
$(document).ready(function () {
$("body").on("mouseover", ".profileLabel", function (e) {
alert($(this).parent().next("div").find("span").first().text());
});
});发布于 2015-04-10 14:20:18
用‘鼠标’代替‘悬停’。
在jQuery 1.8中不推荐,在1.9中删除:名称“悬浮”用作字符串“”的缩写。它为这两个事件附加了一个事件处理程序,处理程序必须检查event.type以确定事件是mouseenter还是mouseleave。不要将“悬停”伪事件名称与接受一两个函数的.hover()方法混为一谈。
https://stackoverflow.com/questions/29562290
复制相似问题