jquery: hide title attribute but not remove it

laukok picture laukok · Oct 7, 2010 · Viewed 45.6k times · Source

I have seen that most people will do it with this solution that on mouse over, we will grab the value in the TITLE attribute, then, remove its value. While on mouse out, we'll put it back on.

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

or

$(this).removeAttr('title'); 

I want to know is it possible just hide the tooltip from appearing than removing the title attribute?

thanks!

Answer

FRotthowe picture FRotthowe · Oct 7, 2010

No you can't, as the browser will decide what to do with the title attribute. You can, however, save it with the node for later reference (and possibly restoring the title):

$(this).data("title", $(this).attr("title")).removeAttr("title");