资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
javascript 操作table的特性
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/> <title>javascript操作table的特性</title> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%3C!--%20%0D%0Afunction%20f()%7B%20%0D%0A%2F%2F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E8%A1%A8%E6%A0%BC%20%0D%0Avar%20oTable%20%3D%20document.createElement(%22table%22)%3B%20%0D%0AoTable.setAttribute(%22border%22%2C%221%22)%3B%20%0D%0AoTable.setAttribute(%22width%22%2C%22300px%22)%3B%20%0D%0A%2F%2F%20%0D%0Avar%20oTBody%20%3D%20document.createElement(%22tbody%22)%3B%20%0D%0AoTable.appendChild(oTBody)%3B%20%0D%0A%2F%2F%E5%88%9B%E5%BB%BA%E7%AC%AC%E4%B8%80%E8%A1%8C%20%0D%0AoTBody.insertRow(0)%3B%20%0D%0AoTBody.rows%5B0%5D.insertCell(0)%3B%20%0D%0AoTBody.rows%5B0%5D.cells%5B0%5D.appendChild(document.createTextNode(%22Cell%201%2C1%22))%3B%20%0D%0AoTBody.rows%5B0%5D.insertCell(1)%3B%20%0D%0AoTBody.rows%5B0%5D.cells%5B1%5D.appendChild(document.createTextNode(%22Cell%202%2C1%22))%3B%20%0D%0A%2F%2F%E5%88%9B%E5%BB%BA%E7%AC%AC%E4%BA%8C%E8%A1%8C%20%0D%0AoTBody.insertRow(1)%3B%20%0D%0AoTBody.rows%5B1%5D.insertCell(0)%3B%20%0D%0AoTBody.rows%5B1%5D.cells%5B0%5D.appendChild(document.createTextNode(%22Cell%201%2C2%22))%3B%20%0D%0AoTBody.rows%5B1%5D.insertCell(1)%3B%20%0D%0AoTBody.rows%5B1%5D.cells%5B1%5D.appendChild(document.createTextNode(%22Cell%202%2C2%22))%3B%20%0D%0A%2F%2F%20glzy8.com%0D%0Adocument.body.appendChild(oTable)%3B%20%0D%0A%7D%20%0D%0A%0D%0A%2F%2F%20--%3E%3C%2Fscript%3E"> </head> <body onclick="f();"> <div>hello</div> <table border="1" width="300px"> <tbody> <tr> <td>Cell 1,1</td> <td>Cell 2,1</td> </tr> <tr> <td>Cell 1,2</td> <td>Cell 2,2</td> </tr> </tbody> </table> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
可以直接点击页面的任何部分即可看到效果。
教程首页
更多教程