下面这段代码,要将选中的复选框删除,但是为什么每次只能删除一半就退出??

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



右部显示区域 // 当全选按钮被选中时,则下边所有复选框都被选中 window.onload = function(){ // 为删除按钮添加响应时间 document.getElementById("del").onclick = function(){ // 获取所有的复选框 var items = document.getElementsByName("items"); setTrId(items); var len = items.length; for(var i = 0;i < len; i++){ alert(len); alert(i); if(items[i] && items[i].checked == true){ var tr = document.getElementById("tr" + (i + 1)); //alert(tr.id); if(confirm("确定要删除该条记录吗?")){ tr.remove(); /*var items = document.getElementsByName("items"); setTrId(items);*/} } } } // 为每个tr的id赋值 function setTrId(items){ for(var i = 0;i < items.length; i++){ var tr = items[i].parentNode.parentNode.parentNode; tr.id = "tr" + (i + 1); } } } <!-- body { margin-left: 3px; margin-top: 0px; margin-right: 3px; margin-bottom: 0px; } .STYLE1 { color: #e1e2e3; font-size: 12px; } .STYLE1 a{ color:#EEE; text-decoration:none;} .STYLE6 {color: #000000; font-size: 12; } .STYLE10 {color: #000000; font-size: 12px; } .STYLE19 { color: #344b50; font-size: 12px; } .STYLE21 { font-size: 12px; color: #3b6375; } .STYLE22 { font-size: 12px; color: #295568; } .page a{ text-decoration:none;} .STYLE21 a{ text-decoration:none;} -->

管理人员基本信息列表
添加  删除    
用户名
用户角色
联系方式
IP地址
详细描述
基本操作
admin
系统管理员
13913612548
192.168.0.124
用户可以对系统的所有操作进行管理...
admin
系统管理员
13913612548
192.168.0.124
用户可以对系统的所有操作进行管理...
    共有 50 条记录,当前第 1 页,共 5
转到
确定


从后往前循环,因为你tr.remove();会改变下标。

能具体修改一下代码吗?刚学

  for(var i = 0;i < len; i++)
 ->
  for(var i = len - 1; i >= 0; i--){