请帮助如何清除Javascript中的下拉列表控件
答案 0 :(得分:8)
document.getElementById('idofselectbox').options.length = 0;
答案 1 :(得分:0)
只需删除<option>
答案 2 :(得分:0)
function RemoveItems()
{
var objDrpList = document.getElementById ('theIdOfYourDdl');
for(i=objDrpList.length-1; i>=0; i--)
{
if(objDrpList.options[i].selected)
{
objDrpList.options[i] = null;
}
}
}
修改强>
达林的回答实际上是要走的路。两者都有效,但代码越少越好。