开发者

How to detect if an attribute contains a certain value in jQuery?

开发者 https://www.devze.com 2023-01-20 04:03 出处:网络
I have elements with various values for an attribute (ids=\"32, 56, 21\"). How can I get the element开发者_开发百科s that contain 21?You want to use this:

I have elements with various values for an attribute (ids="32, 56, 21"). How can I get the element开发者_开发百科s that contain 21?


You want to use this:

$("[ids~=21]")

there must be a space between the attribute values.

You may have to use:

 $("[ids~=21],[ids~=21,]")

see this link: http://api.jquery.com/attribute-contains-word-selector/

0

精彩评论

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