jquery - Select all check box inside a group only in group type multi select dropdown -


when select option options checked in come under 1 group. if select select apple,pear,orange got selected.

<select title="fruits" multiple="multiple" id="fruits" name="fruits[]">         <opt-group label="abc" class="fruit">                 <option label="all" value=""> select all</option>                 <option label="apple" value="1">apple</option>                 <option label="pear" value="2">pear</option>                 <option label="orange" value="3">orange</option>       </opt-group>             <opt-group label="cd" class="berries">                 <option label="all" value="">select all</option>                 <option label="strawberry" value="4">strawberry</option>                 <option label="raspberry" value="5">raspberry</option>                 <option label="blueberry" value="6">blueberry</option> 

if want return items inside of opt-group, need use selector this:

 $("opt-group option") 

or

 $("opt-group").children().find("option") 

it return option within opt-group tag regardless of being selected or not. second 1 suitable when have nested option tags inside of opt-group tag.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -