What is a good way to change the value of a Selectric drop down programmatically based on name? I know the value of the option I want to set as selected. I don't know the name or the index.
Here is my best attempt:
$('.store-availability').prop('selectedIndex', 3).selectric('refresh').change();
Since I don't know the index I would have to jQuery.Index() on the options first to find it or something like that. Is there a cleaner approach?
If you know the value of the option you want to set you can use the setter of val()
, then call refresh
on the selectric instance, like this:
$('.store-availability').val(yourValueHere).change().selectric('refresh');
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