Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Select All Elements That Have a Title

I need to apply a tooltip plugin to a bunch of different elements on my page. The only common property to work with a jQuery selector is that they all have a title property set.

I tried $('[title=*]') as a selector but this didnt work.

like image 550
Jimbo Avatar asked Jun 14 '10 09:06

Jimbo


People also ask

Which of the following selects all h1 and h2?

:header Selector Selects all elements that are headers, like h1, h2, h3 and so on.

Can you select multiple elements in jQuery?

In jQuery, you can select multiple elements by separate it with a comma “,” symbol.


2 Answers

Simply:

$('[title]') 

See also - Has Attribute Selector:

Selects elements that have the specified attribute, with any value.

like image 52
Kobi Avatar answered Sep 24 '22 08:09

Kobi


Also $('[title][title!=]') should work but catches only elements that have title set and not empty (not title="")

like image 42
Keeper Avatar answered Sep 24 '22 08:09

Keeper