2
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懸停時,它會顯示兩個工具提示,一個是空的,另一個是第一個文本的工具提示。當我第二次懸停時,它只顯示空的工具提示。我知道,如果我刪除線:this.title ='';從腳本它將正常工作,但它是顯示兩個工具提示,我的自定義之一,和默認的Windows工具提示。如何解決它?
你在哪裏調用'BindToolTip()'? – Aristos
我編輯了aspx,我用了Sys.Application.add_load(BindToolTip); 在外部UpdatePanel –
你試圖連接'BindToolTip'執行每次你有部分回發? – deostroll