开发者

jQuery regex ^= with number in between

开发者 https://www.devze.com 2023-03-26 10:56 出处:网络
I have elements like user[0][foo], user[0][bar], user[1][foo], user[2][bar] which开发者_StackOverflow are names of select tags.

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 foos 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

0

精彩评论

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