开发者

How to select elements with jQuery that have a certain value in a data attribute array

开发者 https://www.devze.com 2023-04-03 05:35 出处:网络
is there a way in jQuery to sele开发者_如何学Cct elements that have a certain value in a data attribute array?

is there a way in jQuery to sele开发者_如何学Cct elements that have a certain value in a data attribute array?

Consider this snippet of html:

<li id="person1" data-city="Boston, New York, San Fransisco">
    Person name 1
</li>
<li id="person1" data-city="Los Angeles, New York, Washington">
    Person name 2
</li>

What is the best way in jQuery to select all persons with "New York" in the data-city attribute?


even though i don't see your html, it should be:

$('[data-city*="New York"]')
0

精彩评论

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