我想使用基于'title'属性的自定义工具提示,并尝试删除默认行为。它在Firefox中运行良好,但在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 :(得分:1)
你试过把它留空吗?
org_elem.attr("title", "");
答案 1 :(得分:-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属性。