If <a> has title, addClass jQuery?
addclass, html, jquery
Solution
Try
$('a[title]').addClass('toolTip');
Attribute selector is the key :D Selects elements that have the specified attribute with a value exactly equal to a certain value. Finds elements with a title attribute.
More info Has Attribute Selector
Problem
I'm trying to get jQuery automatically detect if a link has a title. I want to create a tooltip for every title attribute. HTML: ``` <a title="This is a title" href="#">link with tooltip</a> ``` How can jQuery detect if a link has a title, and then add a class to that ? ?? ``` $(window).load(function(){ $('a[title=""]').addClass('toolTip'); }); ```