I\'m using jQuery select2 multi select dropdown. I need to select all options in a dropdown from code. Basically there is a Select All checkbox on which this functionality h
If you need a checkbox for this action, just do this simply.
Select/Deselect
Jquery function:
$("#selectall").on('click',function(){
var checked = $("#selectall").prop("checked");
if(checked==true){
$("#myselect > option").prop("selected",true);
}else{
$("#myselect > option").prop("selected",false);
}
});