2012-06-29 80 views
0

我想使用基於'title'屬性的自定義工具提示,並嘗試刪除默認行爲。它在Firefox中運行良好bot在IE9中不起作用。無法刪除IE9中的默認工具提示

我在做這樣的事情:

$(element).on('mouseover mouseout', '[title], [tipText]', function (e) { 
       e.stopPropagation(); 
       e.preventDefault(); 
       if (e.type == 'mouseover') { 
         var org_elem = $(e.currentTarget); 
         var tipText = org_elem.attr('title'); 
         org_elem.attr('tipText', tipText); 
         org_elem.removeAttr('title'); 
//then I create custom tooltip which based on tipText attribute 
.... 

當我繼續前進元素第一次鼠標IE9都提示(默認和自定義)顯示。所有其他時間只顯示自定義工具提示。

那麼如何防止IE9中的默認工具提示?

+0

看起來您需要在加載HTML時應用自定義工具提示,在第一次鼠標懸停發生前刪除標題屬性,而不是在第一次鼠標懸停之後。 –

回答

1

你試過把它留空嗎?

org_elem.attr("title", ""); 
-1

改爲使用JQuery data屬性和方法。這是它製造的那種東西。

相反的:

var tipText = org_elem.attr('title'); 

這將是這樣的:

var tipText = org_elem.data('title'); 

你的HTML是:中

<div data-title="text information that would show up on a tooltip"><div> 

代替:

<div title="text information that would show up on a tooltip"><div> 

實際上您不需要額外的tipText屬性。