<div class="codetitle"> <span><a style="CURSOR: pointer" data="98312" class="copybut" id="copybut98312" onclick="doCopy('code98312')"><u>复代码码</u></a></span> 代码如下:</div> <div class="codebody" id="code98312"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 전환//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br><html xmlns="http://www.w3.org/ 1999/xhtml"><br><head><br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br><title> ;无标题文档</title><br><link rel="stylesheet" href="tab.css" /><br><script type="text/javascript" src="../Day26 /doctool.js"></script><br><script type="text/javascript"><br>function createTab1()<br>{<br> var tabNode = doc.createElement("table ");<br> var tbdNode = doc.createElement("tbody");<br> var trNode = doc.createElement("tr");<br> var tdNode = doc.createElement("td");<br> var textNode = doc.createTextNode("单元格一");<br> tdNode.appendChild(textNode);<br> trNode.appendChild(tdNode);<br> tbdNode.appendChild(trNode);<br> tabNode. appendChild(tbdNode);<br> byTag("div")[0].appendChild(tabNode);<br>}<br>function createTab()<br>{<br> var tabNode = doc.createElement("table ");<br> //tabNode.id = "tabid";<br> tabNode.setAttribute("id","tabid");<br> var row = byName("rownum")[0].value; <br> var col = byName("colnum")[0].value;<br> for(var x=1; x {<br> var trNode = tabNode.insertRow();<br> for(var y=1; y<=col; y )<BR> {<BR> var tdNode.insert 셀() ;<BR> tdNode.innerHTML = x "...." y;<BR> }<BR> }<BR> byTag("div")[0].appendChild(tabNode);<BR> event.srcElement. 비활성화 = true;<BR>}<BR>function delRow()<BR>{<BR> var tabNode = byId("tabid");<BR> if(tabNode==null)<BR> {<BR> 경고 ("表格不存재");<BR> return;<BR> }<BR> var rownum = byName("delrow")[0].value;<BR> if(rownum>0 && rownum<=tabNode.rows .length)<BR> tabNode.deleteRow(rownum-1);<BR> else<BR> {<BR> Alert("删除的行不存재,school习数数很要");<BR> }<BR> }<BR>function delCol()<BR>{<BR> var tabNode = byId("tabid");<BR> if(tabNode==null)<BR> {<BR> Alert("表格不存재 ") ;<BR> return;<BR> }<BR> var colnum = byName("delcol")[0].value;<BR> if(colnum>0 && colnum<=tabNode.rows[0].cells.length )<br> {<br> for(var x=0;x<tabNode.rows.length; x )<br> {<br> tabNode.rows[x].deleteCell(colnum-1);<br> } <br> }<br> else<br> {<br> Alert("删除적列不存재");<br> }<br>}<br></script><br></head> <br><body><br><!--<BR>일반적인 인터페이스를 사용하는 것이 좋습니다.<BR>--><br>동작:<input type="text" 이름 ="rownum" /><br /><br>列:<input type="text" name="colnum" /><br /><br><input type="버튼 " value="创建表格" onclick="createTab()" /><br /><br><input type="text" name="delrow" /><br><input type= "button" value="删除行" onclick="delRow()" /><br><br /><br><input type="text" name="delcol" /><br> <input type="button" value="删除列" onclick="delCol()" /><br><br /><br><br /><br><div><br></div><br></body><br></html><br> </div>