【发布时间】:2012-12-14 14:05:47
【问题描述】:
我想删除表格中的一个元素,
我尝试使用 tr.removeChild(tr.childNodes[2]);
删除我的第三行元素,但它并没有真正起作用
function smile()
{
document.getElementById("p1").style.backgroundImage = 'url(smile.jpg)';
}
function twice()
{
document.getElementById("p2").innerHTML="Smile Smile";
}
function empty()
{
//this is the part i want to remove , i want to remove the text inside it
tr.removeChild(tr.childNodes[3]);
}
</script>
</head>
<body>
<table border = "1" >
<form>
<tr>
<th onclick="smile()"><input type="button" name="person1" value="Make it smile!" id="person4" size="30" </th>
<th onclick="twice()"><input type="button" name="person1" value="Make it smile twice!" id="person4" size="30" </th>
<th onclick="empty()"><input type="button" name="person1" value="Make it empty" id="person4" size="30" </th>
</tr>
【问题讨论】:
-
请注意,重复(和三次)的 id 是无效的,它们必须是唯一的。
标签: javascript node.js removechild