I am trying to get a group of checkboxes by the name attribute. For example, I have 开发者_开发问答the following:
<input name="labs[]" type="checkbox" value="lab1" />
<input name="labs[]" type="checkbox" value="lab2" />
<input name="labs[]" type="checkbox" value="lab3" />
<input name="labs[]" type="checkbox" value="lab4" />
And Im trying to get that group by doing something like:
Ext.query('input[name=labs[]]');
But that clearly doesn't work because of the square brackets that are part of the name. I'm lost as to how to do this?
You could do a "starts with" match instead:
Ext.query('input[name^=labs]');
This will not work very well if you have other elements that start with "labs" though, so you may want to add another identifier to your "labs[]" name, i.e. "labs-check[]".
Try matching an input element that has a name attribute that starts with 'labs':
Ext.query("input[name^=labs]");
精彩评论