简体   繁体   中英

Can't remove default tooltip in IE9

I want to use custom tooltip based on 'title' attribute, and try to remove default behavior. It works good in Firefox bot doesn't work in IE9.

I'm doing something like this:

 $(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
....

When I move mouse on element first time in IE9 both tooltip (default and custom) are displayed. All other times only custom tooltip displayed.

So how to prevent default tooltip in IE9?

您是否尝试将其留空?

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

Use the JQuery data attribute and methods instead. This is the kind of thing it's made for.

Instead of:

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

It would be something like:

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

Your HTML would be:

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

instead of:

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

You actually wouldn't need the extra tipText attribute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM