How do you preselect an option in a multiple select html tag using jquery's val()?
What I mean by this is that say you have a multiselect component and you want some of the values to be preselected?
Assuming I've understood your question correctly, you can pass an array of values to the .val() method:
$("#yourSelect").val(["value1", "value2"]);
Here's a working example.
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