【问题标题】:Jquery Chosen Add dynamically OptionJquery选择动态添加选项
【发布时间】:2013-11-06 01:48:54
【问题描述】:

我正在使用 jquery 插件(选择)输入名称选择框

在我的工作限制中

  1. 在 input type=text 元素中输入一个元素(使用选择的插件选择框)

  2. 从弹出窗口输入一个输入类型=文本元素到选定的用户名。

我想在选择框中添加动态选项。

所以,我被添加到了选择的子节点中;

这是我的 HTML 代码

 <select data-placeholder="Please enter your name" class="chosen-select chosen_member2" multiple style="min-width:400px;width:auto;float:left;height: 30px;" tabindex="4">
                            </select>

这是我的 Jquery 代码

$(".chosen-choices").eq(0).find(".search-field").before("<li class=\"search-choice\"><span>"+uname+" (Executive Dept)</span><a class=\"search-choice-close\" data-option-array-index=\""+auto_num+"\"></a></li>");

$('.chosen-choices').eq(0).trigger("chosen:updated");

并且,成功添加选项元素。

如果将选项元素添加到选择框中,则其中一个下拉项处于非活动状态。

但是,在我的例子中,将一个元素添加到一个选择中,其中一个下拉项是活动的。

因此!,

虽然添加了一个元素,但选项元素仍然是活跃的。 (当我将输入类型 = 文本元素添加到选择的选择类时,我需要非活动选项)

【问题讨论】:

    标签: jquery


    【解决方案1】:

    希望没有被选中的可能,所以试试select2

    http://ivaynberg.github.io/select2/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多