开发者

Get group of checkboxes by name attribute in ExtJS

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]");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜