我是 jquery 的早期爱好者。如何动态设置 selectizer.js 的值。我的 html 中的值没有改变。始终显示相同的值。
最佳答案
您可以使用setValue
函数。 See docs here .
示例:
<select id="selectize" class='select-edit' multiple>
<option value=opt0>Option 0</option>
<option value=opt1>Option 1</option>
</select>
$(function() {
$('#selectize').selectize();
var selectize_tags = $("#selectize")[0].selectize;
selectize_tags.setValue('opt0');
});
关于javascript - 如何动态更改jquery中的选择器setValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32264239/