日期:2014-05-16 浏览次数:20419 次
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>new page</title> </head> <body> <table > <tr > <td >娃哈哈 </td > <td >笑笑笑 </td > </tr > <td >小强 </td > <td >旺财 </td > </tr > </table > </body> <script> var t=document.getElementsByTagName("table")[0]; t.deleteRow(0); </script> </html>
------解决方案--------------------
function deleteCell() { var trs=$("tr"); for(var i=0;i<trs.length;i++) { var theTr=trs[i]; if(theTr.firstChild) theTr.removeChild(theTr.firstChild); } } function $(tagName) { return document.getElementsByTagName(tagName); }