jQuery regex ^= with number in between
I have elements like
user[0][foo], user[0][bar], user[1][foo], user[2][bar]
which开发者_StackOverflow are names
of select
tags.
I want use the ^=
operator to use jQuery('select[name^=
(something)')
so that I can gather all the foo
s together.
Is there anything stopping you using the ends with selector instead?
jQuery('select[name$="foo\\]"]');
Note we're having to escape the "]
" as it's a "meta-characters":
If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, you must escape the character with two backslashes: \\. For example, if you have an element with id="foo.bar", you can use the selector $("#foo\\.bar")
http://api.jquery.com/category/selectors
精彩评论