简体   繁体   中英

How do you change the selected option of a jquery selectric element using javascript?

I can change the original select's selected option by doing something like-

$('#mySelectList option:first').prop('selected', true)

but that doesn't update the selectric display of the select.

According to this pull request , you can "refresh" the plugin:

$('#mySelectList').prop('selectedIndex', 0).selectric('refresh');

From the documentation:

$('select').selectric('refresh'); // Reconstruct the instance of plugin

要根据它的值改变selectric,这可行:

$('#mySelectList').val(someValue).selectric('refresh');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM