如何清除Selectize.js下拉列表中的选定值? [英] How to clear a selected value in Selectize.js dropdown?

查看:287
本文介绍了如何清除Selectize.js下拉列表中的选定值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 selectize.js 下拉菜单,我必须清除选择的值.

I have a selectize.js dropdown and I have to clear the selected value .

我已经尝试过此操作(如另一项建议问题):

I have tried this (as suggested in another question):

var selectize = $("#optionNetFlow")[0].selectize;
selectize.clear();

但是它给出了以下错误:

But it gives the following error:


当我将其更改为此:


When I change it to this:

var selectize = $("#optionNetFlow").selectize;
selectize.clear();

我给出了此错误:


我在这里做错了什么?


What I am doing wrong here?

推荐答案

我终于在这里找到了答案 Selectize.js演示

I finally found the answer here Selectize.js Demos

对我有用的是:

 var $select = $('#optionNetFlow').selectize();
 var control = $select[0].selectize;
 control.clear();

在应用上述问题的答案中提供的解决方案之前,我缺少了var $select = $('#optionNetFlow').selectize();.

what I was missing var $select = $('#optionNetFlow').selectize(); before applying the solution provided in above question's answer.

现在我要在控制台中获得所有功能,如:

Now I am to get all the functions in console like :

这篇关于如何清除Selectize.js下拉列表中的选定值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆