javascript - jQuery set Multi Select OptGroup options -
i have multi-select list optgroups so:
<select multiple="multiple" id="idcountry"> <optgroup label="asia"> <option value="australia">australia</option> <option value="china">china</option> </optgroup> <optgroup label="europe"> <option value="france">france</option> <option value="uk">uk</option> </optgroup> </select> how can have jquery select destinations in europe user label? how unselect destinations in optgroup label well?
added ejay's amusement. i've tried doesn't work , don't know go here.
$(".chkregion").click(function () { if (this.checked) { var optgroup = $('select optgroup[label="' + this.checked + '"]') optgroup.attr('selected', true); } });
to set
$('optgroup[label=europe] option').prop('selected',true); change label value , boolean accordingly unselect
Comments
Post a Comment