Jeff
Jeff

Reputation: 6110

jQuery, How to target very specific selectors?

Apologies if this has been asked already, I can't find the answer in the jQuery docs.

How would I select all .tooltip classes which have a [title] attribute, and the [title] attribute is not empty?

In other words, select these:

<a href="#" class="tooltip" title="YES">Foo</a>
<span class="tooltip" title="YES">Bar</span>

But not these:

<a href="#" class="tooltip" title="">Empty title attribute.</a>
<span class="tooltip">No title attribute.</span>

Upvotes: 2

Views: 1285

Answers (1)

Gumbo
Gumbo

Reputation: 655129

Try this selector:

.tooltip[title]:not([title=""])

Upvotes: 5

Related Questions