清除 IE 中的<选择>下拉列表
clear <select> dropdown in IE
我正在尝试清除带有子项的类型下拉列表,JQuery Empty()命令适用于Chrome(我假设所有其他浏览器),但不适用于Internet Explorer。
我试过这个
document.getElementById("dropdown").length = 0;
或
document.getElementById("dropdown").innerHtml("");
但返回
document.getElementById(...)' is null or not an object
.
var DropDown = $("#dropdown");
Dropdown.Length = 0;
似乎没有任何效果(不确定是否可以在 JQuery 变量上使用纯 JavaScript 方法?
有什么可靠的方法来清除Internet Explorer中的元素吗?
HTML 很混乱,因为它是从 SharePoint 中的 ASP 生成的,但这是浏览器和 JavaScript 从中读取的相关输出
我正在使用Jquery 1.11.3(来自谷歌APIS)和IE浏览器11
<tr>
<td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
<nobr>Interaction Contact</nobr>
</h3></td>
<td valign="top" class="ms-formbody">
<!-- FieldName="Interaction Contact"
FieldInternalName="Interaction_x0020_Contact"
FieldType="SPFieldLookup"
-->
<span dir="none"><select name="ctl00$m$g_d04d1ad3_87fc_4751_9c85_4974c40486ca$ctl00$ctl05$ctl07$ctl00$ctl00$ctl04$ctl00$Lookup" id="ctl00_m_g_d04d1ad3_87fc_4751_9c85_4974c40486ca_ctl00_ctl05_ctl07_ctl00_ctl00_ctl04_ctl00_Lookup" title="Interaction Contact">
<option selected="selected" value="0">(None)</option>
<option value="15788"> John doe , john-doe@mail.net</option>
<option value="15788"> John doe , john-doe@mail.net</option>
<!-- lots of <option> elements that needs to be cleared -->
</select><br></span>
</td>
</tr>
在jquery中,你可以跨浏览器清除它:
$("#dropdown").empty()
尝试:
document.getElementById("dropdown").options.length = 0;
要使用 jQuery 执行此操作:
$('#dropdown').empty();
相关文章:
- 如何使用jQuery选择下拉列表的值
- Jquery 读取编号组中选择下拉列表的数组
- 使用$_POST值选择下拉列表
- 使用Ajax或JavaScript选择下拉列表选项后,在同一页面上执行PHP脚本
- 根据url填充表单选择下拉列表
- 使 URL 开始选择下拉列表
- 引导程序选择下拉列表
- 如何通过选择下拉列表中的选项从另一个 php 文件中获取数据
- 保持元素处于禁用状态,直到未在 Angularjs 中选择下拉列表
- Knockoutjs - 单击按钮时打开选择下拉列表
- 使用选择下拉列表的性别角度过滤器
- 如何根据选择下拉列表从表单重定向到 URL
- 如果未选择第一项,请选择下拉列表 jQuery
- 选择下拉列表需要在选中时显示提供商的详细信息-无法通过我的脚本显示url
- 使用对象(JavaScript或jQuery)填充选择下拉列表
- 如何在选择下拉列表值的文本框中获取值
- 删除基于先前下拉列表选择的“选择下拉列表”选项
- jQuery验证插件-比较两个选择下拉列表的自定义方法
- 通过ajax选择下拉列表
- JavaScript:使用用于Protractor测试的页面对象选择下拉列表项