Easy way to quick select a whole optgroup in select box

前端 未结 4 973
星月不相逢
星月不相逢 2021-01-02 20:32

I have a select box in which i can select multiple options. In the select box are multiple optgroups. Is there an easy way to select a whole optgroup at once in javascript?

4条回答
  •  有刺的猬
    2021-01-02 21:00

    I'm normally against using jQuery for simple jobs like this but I can see its value here. Still, if you prefer a non-jQuery solution that will have the benefits of using no library, introducing no spurious ids or classes and running faster, here is one:

    
    
                                     
                  
提交回复
热议问题