When we use multi select drop down, we may consider the feature for selecting all and deselect all option for the respective Multi Select box.
Using jQuery, we can easily do the select all and deselect all option for the dropdown.
Below is the code to select all using jQuery
HTML
<select name="education" id="education" multiple="multiple">
<option value="1">Under Graduate</option>
<option value="2">Graduate</option>
<option value="3">Post Graduate</option>
<option value="4">Pursuing Graduation</option>
</select>
$('#education').find('option').attr('selected','selected');
Where 'education' is the id for the multi select & we are adding the attribute selected to get selected.
To deselect all using jQuery.
$('#education').find('option').removeAttr('selected','selected');
No comments:
Post a Comment