我有以下代码:
function removeUsers()
{
var removedUsers = document.getElementById('<%=removedUsers.ClientID%>');
var lbCurrent = document.getElementById('<%=lbCurrent.ClientID%>');
if (lbCurrent && lbCurrent.selectedIndex != -1)
{
for(i=lbCurrent.length-1; i>=0; i--)
{
if(lbCurrent.options[i].selected)
{
//add the removed user to the removedUsers var
removedUsers.value += lbCurrent.options(i).value + ";";
lbCurrent.options[i] = null;
}
}
}
selectAllItems();
}
这导致我在 firefox 中出现问题:
removedUsers.value += lbCurrent.options(i).value + ";";
有人可以帮忙吗??
谢谢
最佳答案
removedUsers.value += lbCurrent.options(i).value + ";";
应该是
removedUsers.value += lbCurrent.options[i].value + ";";
假设 lbCurrent.options
是一个数组
。
关于javascript - 如何删除选择字段中的列表选项项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9587017/