我想删除表格中的一个元素,
我尝试使用 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>