我有一个用于显示工具提示的脚本
function BindToolTip(){
$('.toolTip').hover(
function () {
this.tip = this.title;
$(this).append(
'<div class="toolTipWrapper">'
+ '<div class="toolTipTop"></div>'
+ '<div class="toolTipMid">'
+ this.tip
+ '</div>'
+ '<div class="toolTipBtm"></div>'
+ '</div>'
);
this.title = '';
this.width = $(this).width();
$(this).find('.toolTipWrapper').css({ left: this.width - 22 })
$('.toolTipWrapper').fadeIn(300);
},
function () {
$('.toolTipWrapper').fadeOut(100);
$(this).children().remove();
this.title = this.tip;
}
);
}aspx文件如下所示:
<asp:UpdatePanel ID="UpdatePanelAddNews" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<script type="text/javascript">
Sys.Application.add_load(BindToolTip);
</script>
<div class="toolTip" title="This is a simple tooltip made with jQuery"></div>
<asp:UpdatePanel ID="UpdatePanelDate" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownListYearStart" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="OnSelectedStartDateChanged" CssClass="dropdown"> </asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>当我悬停div时,它正确地显示了工具提示,但在使用dropdownlist进行回发后,当我第一次悬停div时,它显示了两个工具提示,一个是空的,另一个工具提示后面有文本。当我第二次悬停时,它只显示空的工具提示。我知道如果从脚本中删除line: this.title =‘’,它将正常工作,但它将显示两个工具提示,我的自定义工具提示和默认的windows工具提示。如何解决?
发布于 2012-10-09 23:37:39
在ContentTemplate的最后编写您的脚本。喜欢,
<asp:UpdatePanel ID="UpdatePanelAddNews" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div class="toolTip" title="This is a simple tooltip made with jQuery"></div>
<asp:UpdatePanel ID="UpdatePanelDate" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownListYearStart" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="OnSelectedStartDateChanged" CssClass="dropdown"> </asp:DropDownList>
<script type="text/javascript">
Sys.Application.add_load(BindToolTip);
</script>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>希望能有所帮助。如果它解决了你的问题,别忘了给它加票。谢谢..:)
https://stackoverflow.com/questions/10871615
复制相似问题