0

我想使用基于“标题”属性的自定义工具提示,并尝试删除默认行为。它在 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中的默认工具提示呢?

4

2 回答 2

1

你试过让它空着吗?

org_elem.attr("title", "");
于 2012-06-29T15:49:53.650 回答
-1

请改用 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 属性。

于 2012-06-29T16:12:11.680 回答