Remove title tag tooltip
Solution 1
it's all about the browser. It's the browser that see the title
as a tooltip, from the browser specifications and interpretations.
you should use, if you want to handle data like that, the HTML5 way (witch you can use in any other document type as it's ignored) and use:
<a href="url" data-title="anotherURL"></a>
with the data-
attributes, there will be no tooltip as title
is not used, and you can easily get that using:
$("a").attr("data-title")
but, you will need to convert stuff and you said that you don't/can't do that.
you can easily convert all title
's into data-title
and clean the title using
$("a").attr("data-title", function() { return $(this).attr("title"); } );
$("a").removeAttr("title");
(all code is to be used with jQuery Framework)
Solution 2
As you didn't mark this question as jquery, I'm assuming that you'd be open to a pure JavaScript solution?
The following works (on Ubuntu 11.04) in Firefox 5, Chromium 12 and Opera 11, I'm unable to test in IE, but as I'm using querySelectorAll()
I'd suspect that it wouldn't work well, if at all. However:
var titled = document.querySelectorAll('[title]'); // gets all elements with a 'title' attribute, as long as the browser supports the css attribute-selector
var numTitled = titled.length;
for (i=0; i<numTitled; i++){
titled[i].setAttribute('data-title',titled[i].title); // copies from 'title' to 'data-title' attribute
titled[i].removeAttribute('title'); // removes the 'title' attribute
}
References:
Tobias
Dedicated designer and developer Check out my soundcloud for great music! https://soundcloud.com/john-arth
Updated on July 08, 2020Comments
-
Tobias almost 4 years
Is there any way to remove the tooltip from title attribute without actually remove the title.
I have a link with a title attribute like this
<a href="url" title="anotherURL"></a>
It is important that the title is intact since I need to read the url from there. All the fixes for this that I have found is to remove the title attribute and reuse it but in this case this is not possible.
Any ideas?
-
EdoDodo almost 13 yearsWhy do you need to have a title attribute if you don't want a tooltip? The only reason to have a title attribute is to display a tooltip...
-
Tobias almost 13 yearsI need it for swfadress to read the separate url. I could do it with rel tags instead but got problems with IE
-
Quentin almost 13 yearsIf you want to store arbitrary data in an attribute, then use HTML 5's data-*. Don't abuse an existing attribute with a defined purpose.
-