<html>
<head>
<script>
function deleteTable() {
var oParent = document.getElementById("tb1").parentNode;
oParent.removeChild(document.getElementById("tb1"));
}
</script>
</head>
<body>
<table id="tb1" style="border:1px solid blue;">
<tr>
<td>hello1<td/><td>hello2<td/><td>hello3<td/>
<tr/>
<tr>
<td>hello1<td/><td>hello2<td/><td>hello3<td/>
<tr/>
<tr>
<td>hello1<td/><td>hello2<td/><td>hello3<td/>
<tr/>
<tr>
<td>hello1<td/><td>hello2<td/><td>hello3<td/>
<tr/>
</table>
</body>
</table> <input type="button" value="delete" onclick="deleteTable()"/>
</html>
解决方案 »
- 庖丁解牛——由企业级应用与网站的疑惑想到的~~~
- o.attachEvent( 'onclick' ,t ); function t(){ alert( 'this:' + this ); } 这里的this应该是什么?
- Uploadify 3.2全部取消队列问题,求助大神
- 如何在没有提交页面的情况下,取“列表/菜单”的值
- 关于flash中调用javascript的问题,急,大虾帮忙!
- javascript可以读写文本文件吗?
- 如何让页面刷新之后不记住上次的checkbox选择?
- 帮我看看页栏的修改问题!谢谢!
- 打开主页,怎样以跳转覆盖主页的形式打开我的FLASH(.swf)页面
- 为什么有ie和netscape两个浏览器!!!
- 高分急求opener.document动态添加父窗口表格的问题
- JS问题:在onKeyUp按钮中调用方法,Ajax猜想姓名,发现在输入第一个字后输入第二个字ie很卡,如何延迟
<html>
<head>
<script>
function deleteTable() {
var oParent = document.getElementById("tb1").parentNode; //获取table的父结点
oParent.removeChild(document.getElementById("tb1")); //从table的父结点中删除table子结点
}
</script>
</head>
<body>
<table id="tb1" style="border:1px solid blue;">
<tr>
<td>hello1<td/><td>hello2<td/><td>hello3<td/>
<tr/>
<tr>
<td>hello1<td/><td>hello2<td/><td>hello3<td/>
<tr/>
<tr>
<td>hello1<td/><td>hello2<td/><td>hello3<td/>
<tr/>
<tr>
<td>hello1<td/><td>hello2<td/><td>hello3<td/>
<tr/>
</table>
</body>
</table> <input type="button" value="delete" onclick="deleteTable()"/>
</html>加点注释 :-)
<table>
.....
</table>
</div>
<input type=button value="删除表格" onclick="document.getElementById('tbl').innerHTML='';">如果不要占位的话,onclick后面改为onclick="var o=document.getElementById('tbl');o.innerHTML='';o.style.display='none'"
<input type="button" value="delete" onclick="this.parentNode.removeChild(this);">
然后 obj.parentNode.removeChild(this);
看来以后不能再上论坛了.obj.parentNode.removeChild(obj);