我有一个selectize.js下拉菜单,我必须清除所选的值.
我试过了 :
var selectize = $("#optionNetFlow")[0].selectize;
selectize.clear();
Run Code Online (Sandbox Code Playgroud)
如另一个问题中所建议的如何以编程方式设置selectize.js选项列表.但它给出了一个错误,
Uncaught TypeError: Cannot read property 'selectize' of undefinedmessage: "Cannot read property 'selectize' of undefined"stack: (...)get stack: function () { [native code] }arguments: nullcaller: nulllength: 0name: ""prototype: StackTraceGetterconstructor: function () { [native code] }__proto__: Object__proto__: function Empty() {}<function scope>set stack: function () { [native code] }__proto__: Error
Run Code Online (Sandbox Code Playgroud)

当我把它改为:
var selectize = $("#optionNetFlow").selectize;
selectize.clear();
Run Code Online (Sandbox Code Playgroud)
我给出了错误:
TypeError: undefined is not a functionmessage: "undefined is not a function"stack: (...)get stack: function () { …Run Code Online (Sandbox Code Playgroud)