我正在使用这个 Jquery Comboxbox
/*!
* Combobox Plugin for jQuery, version 0.5.0
*
* Copyright 2012, Dell Sala
* http://dellsala.com/
* https://github.com/dellsala/Combo-Box-jQuery-Plugin
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Date: 2012-01-15
*/
我可以将数据绑定(bind)到它:
$('#' + selectorId).combobox(data);
其中data是一个数组。
但是一旦数据绑定(bind),我就无法删除/清除。添加时它会继续在先前的组合框上添加另一个组合框。我已经尝试过了
$('#' + selectorId).empty();
但它不起作用。
已生成 HTML
<span class="combobox" style="position:relative; display:-moz-inline-box; display:inline- block;">
<input name="ctl00$ContentPlaceHolder1$DropoffLocation$txtDropoffAMeetPoint" type="text" id="txtDropoffAMeetPoint" class="txt txtDropoffAMeetPoint combo_textbox" onblur="return _setEditRideStopMeetPointService(false, true, this);" style="margin: 0px 32px 0px 0px;">
<a href="#" class="combobox_button" style="position:absolute; height:32px; width:32px; top:0; left:351px;"><div class="combobox_arrow"></div></a>
<div class="combobox_selector" style="display:none; width:351px; position:absolute; left: 0; top: 32px;">
<ul>
<li>Baggage Claim Meet</li>
<li>Curbside - Wait in Holding</li>
<li>Meet Outside Customs</li>
<li></li>
</ul>
</div>
</span>
其中名称为 ctl00$ContentPlaceHolder1$DropoffLocation$txtDropoffAMeetPoint 的输入是它所绑定(bind)的文本框。它由绑定(bind)时的 span 标记包围。
最佳答案
一旦您的组合框充满了数据,为了删除/清除以前的数据,请尝试以下操作:-
jQuery.combobox.instances[0].setSelectOptions(newdata);// where 'newdata' is an array
关于javascript - 清除/删除 Jquery 组合框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26795460/