How to detect if an attribute contains a certain value in jQuery?
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/
精彩评论