开发者

Jquery - Be able to select items in drop down by group?

I have a drop down that has the group label:

<optgroup label="Numbers">

    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>

</optgroup>
<optgroup label="Letters" disabled="true">

    <option value="4">A</option>
    <option value="5">B</option>
    <option value="6">C</option>

</optgroup>

Is there a jquery plugin that exist that will allow me to click the group label and that will auto select all the op开发者_开发技巧tions in that group? Or if not does anyone know how this can be done in jquery, if it can be done at all? Basically I want to click the optgroup label as an option, when I do that all options assigned to that group will be selected/checked.


Using a combination of css classes and the jquery children() method should do the trick. This answer gives a good example: Easy way to quick select a whole optgroup in select box

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜