I have a multi-select html dropdown. I want to programatically (via jquery) select all values in the dropdown. How can I do this?
Where the select has the id test
$('#test option').attr('selected', 'selected');
JSFiddle Example
Or as Ryan mentioned you can use .prop
$('#test option').prop('selected', true); // or pass false to deselect them
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With