简体   繁体   English

如何使用javascript更改jquery selectric元素的选定选项?

[英]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. 但是这不会更新选择的selectric显示。

According to this pull request , you can "refresh" the plugin: 根据此pull请求 ,您可以“刷新”插件:

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

From the documentation: 从文档:

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

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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