getElementsByID或者Name取到Table
.ParentNode取他父节点
然后找 Table所在的子节点(具体哪个根据代码判断)删除
然后把<div>加到那个位置就行了

解决方案 »

  1.   


    <html>
    <head>
    <title>FocusTest</title>
    <script>
    function newCreate(){
    document.getElementById('tbl').removeNode(true);
    var newDiv =document.createElement('DIV');
    newDiv.ID="iDiv";
    newDiv.innerText="DIV";
    newDiv.style.background="red";
    document.body.appendChild(newDiv);
    }
    </script>
    </head><body>
    <form>
    <table id="tbl" bgcolor="blue">
    <tr><td>table</td></tr>
    </table>
    <input type="button" value="切&#25442;" onclick="newCreate()">
    </form>
    </body>
    </html>