Js动态删除行(支持FireFox)

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>


http://www.cnblogs.com/Kennytian/archive/2008/01/11/1034797.html

你可能感兴趣的:(html,XHTML,div,firefox,button)