开发者

jQuery, How to target very specific selectors?

开发者 https://www.devze.com 2022-12-12 03:35 出处:网络
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?

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" 开发者_JS百科title="">Empty title attribute.</a>
<span class="tooltip">No title attribute.</span>


Try this selector:

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

精彩评论

暂无评论...
验证码 换一张
取 消