现在的位置: 首页 > 综合 > 正文

[原] Js动态删除行(支持FireFox)

2011年12月01日 ⁄ 综合 ⁄ 共 880字 ⁄ 字号 评论关闭
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<style type="text/css" media="all">
dd
{display:inline;}
</style>
<script type="text/javascript">
function del(rowIndex) {
  
var div1ChildNodes = document.getElementById("div1").childNodes.length;
  alert(div1ChildNodes);
  
var dlRowIndex = "dl" + rowIndex;
  
var oDl = document.getElementById(dlRowIndex);
  oDl.parentNode.removeChild(oDl);
}
</script>
</head>
<body>
<div id="div1">
  
<dl id="dl1"><dd>11</dd><dd>12</dd></dl>
  
<dl id="dl2"><dd>21</dd><dd>22</dd></dl>
  
<dl id="dl3"><dd>31</dd><dd>32</dd></dl>
  
<dl id="dl4"><dd>41</dd><dd>42</dd></dl>
</div>
<input id="btn" value="del row" type="button" onclick="del(1)" />
</body>
</html>

用Js删除一行 动态删除一行 删除li 删除dl
取子节点数 取子节点个数
写了这么多无聊的Keywords,只是希望大家能搜索到 :)

抱歉!评论已关闭.