i have a lot of input fields like:
<input type="hidden" value="" name="participants[1][canceled]">
<input type="hidden" value="" name="participants[2][canceled]">
<input type="hidden" value="" name="participants[3][canceled]">
I am looking for a jQuery selector that gives me all of these items. I dont want to use a loop. I would prefer something like:
jQuery('[name="participants[*][canceled]"]') // actually dont work
Is that possible?
Thank you
EDIT: Thanks to all of you
$(':hidden[name^="participants["][name$="][canceled]"]');
Was my solution and works like a charm. Ty
If you just want the array name
then you can just use participants
jQuery('[name*=participants]')
To be precise this is the correct way:
$(':hidden[name^="participants["][name$="][canceled]"]');
Or if you need to match numbers only:
$(':hidden').filter(function() {
return /^participants\[\d+\]\[canceled\]$/.test(this.name);
});
我会使用类似$("input:hidden[name^='participants']")
试试这个: Refreence
$('[name ="participants"][name $="[canceled]"]')
尝试这个:
jQuery('[name^="participants"][name$="[canceled]"]')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.