如何使用jQuery从自动完成选择列表中删除选项

时间:2017-05-30 12:37:24

标签: javascript jquery jquery-ui

我想从自动完成输入下拉选择列表中删除该选项。

除非我点击输入下拉列表,否则无法获取选项值。一旦我点击输入字段,选项就会自动填充,但我不知道如何在这里获得选项。

点击之前的输入字段:



<div class="field-group">
    <label for="add-reminders-role-picker">Project Role</label>
     <div class="aui-ss" id="add-reminders-role-picker-single-select">
		<input autocomplete="off" class="text aui-ss-field ajs-dirty-warning-exempt" id="add-reminders-role-picker-field">
		<div class="aui-list" id="add-reminders-role-picker-suggestions" tabindex="-1"></div>
		<span class="icon aui-ss-icon noloading drop-menu"><span>More</span></span></div>
	<select class="aui-field-select select aui-ss-select" name="roleName" id="add-reminders-role-picker" multiple="multiple" style="display: none;">
        <option value=""></option>
    </select>
</div>
&#13;
&#13;
&#13;

点击输入栏后:

&#13;
&#13;
<div class="field-group">
    <label for="add-reminders-role-picker">Project Role</label>
	<div class="aui-ss" id="add-reminders-role-picker-single-select" data-query="">
		<input autocomplete="off" class="text aui-ss-field ajs-dirty-warning-exempt" id="add-reminders-role-picker-field">
		<div class="ajs-layer-placeholder">
			<div class="ajs-layer box-shadow" style="width: 248px; position: fixed; left: 153.667px; top: 399.167px; max-height: 171.833px; display: none;">
				<div class="aui-list" id="add-reminders-role-picker-suggestions" tabindex="-1" style="display: block;">
					<div class="aui-list-scroll" tabindex="-1">
						<h5>Project role</h5>
							<ul class="aui-list-section aui-last" id="project-role">
								<li class="aui-list-item aui-list-item-li-administrators active">
									<a class="aui-list-item-link" href="#" title="Administrators">Administrators</a>
								</li>
								<li class="aui-list-item aui-list-item-li-developers">
									<a class="aui-list-item-link" href="#" title="Developers">Developers</a>
								</li>
								<li class="aui-list-item aui-list-item-li-event-watchers">
									<a class="aui-list-item-link" href="#" title="Event Watchers">Event Watchers</a>
								</li>
								<li class="aui-list-item aui-list-item-li-privilege-users">
									<a class="aui-list-item-link" href="#" title="Privilege Users">Privilege Users</a>
								</li>
								<li class="aui-list-item aui-list-item-li-users">
									<a class="aui-list-item-link" href="#" title="Users">Users</a>
								</li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		<span class="icon aui-ss-icon drop-menu noloading"><span>More</span></span></div>

	<select class="aui-field-select select aui-ss-select" name="roleName" id="add-reminders-role-picker" multiple="multiple" style="display: none;">
		<option value=""></option>
	</select>
</div>
&#13;
&#13;
&#13;

在这里,我想删除&#34;用户&#34;来自&#39; li&#39;的选项在第二个代码段中。请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

尝试:

$('#aui-list-item-li-users').remove();

此代码将使用class = aui-list-item-li-users

删除'li'