[英]Can't remove default tooltip in IE9
我想使用基於“標題”屬性的自定義工具提示,並嘗試刪除默認行為。 它在Firefox bot中很好用,在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中的默認工具提示?
您是否嘗試將其留空?
org_elem.attr("title", "");
請改用JQuery 數據屬性和方法。 這就是它的目的。
代替:
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屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.