Problem: How to Remove Tooltips From Links

Anchor tag title attributes. I know you hate them. But hey! You would think that they're helpful, and in most cases should be helpful when regarding accessibility. However, the title attribute is useless for touch screen users or keyboard-only users. What's worse, the title tag is not read aloud by screen readers. So what are they for?

Well the one thing is that it gives extra information about an element. And when you hover over the element, you can get a tooltip displaying what you have entered for that attribute. I mean, that's helpful if someone has a link that looks like this: http://imgr.com/38429q3734 and they feel wary about what they are about to click. But if you have an image, the alt attribute will already do this for you (and it will be read aloud just fine) and it is therefore unnecessary to repeat what's on the alt attribute, in the title attribute.

So lets say that we have told you this a bit too late, and you have already populated every link in your site with the title attribute. Here's how to get rid of those pesky things all at once!

Fix: Get Rid of Title Attribute Tag, Completely

I have the solution for completely removing the title tag from all of the anchor tags in your site. Simply copy and paste this into your JavaScript file. (I've pasted mine after the jQuery(function ($) { start).

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

Et voila! This code completely removes the title attribute from all the a tags on your site. Just take note, if you remove this line of code, the title tags will be right back, so this does not necessarily destroy your title attributes.

This function, removeAttr() is useful for just about any element on your page, for instance.

$('li').removeAttr('class');

Although the above example is pretty senseless, it will do as told. It will remove the class attribute from all of the list tags from your site. Let's look at another approach.

Fix: Change the Contents of the Title Attributes... Or Any Attributes

Here's a cool and different approach. With this next line of code, you can select an attribute of an element and change what its values are. For the title attribute, you can even make it blank.

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

Let's say you want all of your li tags to have a class of 'cookies'. You can enter this code:

$('li').attr('class', 'cookies'); 

There you have it! Go onward with your newfound knowledge and be careful — always backup your site before trying anything new!

Add comment


Security code
Refresh

Search

Visit fbetting.co.uk Betfair Review