How to select all values in drop down list by clicking a button using jQuery in JavaScript?
Thanks in advance
How to select all values in drop down list by clicking a button using jQuery in JavaScript?
Thanks in advance
$(function(){
$('select').children('option').attr('selected', 'selected');
});
Should do it. Of course you would need a SELECT element with attribute multiple.
This solution works with plain multi-select lists and multi-select lists that have optgroups.
$("select option").attr("selected", "true");
Note: This is the HTML answer, for XHTML selected should equal "selected", rather than true.