Rob Stevenson-Leggett
Rob Stevenson-Leggett

Reputation: 35679

How to stop title attribute from displaying tooltip temporarily?

I've got a popup div showing on rightclick (I know this breaks expected functionality but Google Docs does it so why not?) However the element I'm showing my popup on has a "title" attribute set which appears over the top of my div. I still want the tooltip to work but not when the popup is there.

What's the best way to stop the tooltip showing while the popup is open/openning?

Edit: I am using jQuery

Upvotes: 5

Views: 9310

Answers (4)

Jack
Jack

Reputation: 3415

For me, I didn't care what the content of the title tag was. I just did:

$('a').hover(function() {

    $(this).attr('title', '');

});

Which stopped the title tag from showing.

Upvotes: 1

Nazariy
Nazariy

Reputation: 6088

Here is another example of how it can be done by using data for value storage and prop for value assigning

$('[title]').on({
    mouseenter : function()
    {
        $(this).data('title', this.title).prop('title', '');
    },
    mouseleave: function()
    {
        $(this).prop('title', $(this).data('title'));
    }
});

Upvotes: 3

Josh
Josh

Reputation: 18690

With jquery you could bind the hover function to also set the title attribute to blank onmouseover and then reset it on mouse out.

$("element#id").hover(
 function() {
  $(this).attr("title","");
  $("div#popout").show();
 },
 function() {
  $("div#popout").hide();
  $(this).attr("title",originalTitle);
 }
);

Upvotes: 4

Javier Suero Santos
Javier Suero Santos

Reputation: 572

I think setting to blank space and when the popup closes, setting again the proper text. I think this is the easiest way to stop it.

Upvotes: 0

Related Questions