javascript中创建table
2013-12-04 17:48
393 查看
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jstable.aspx.cs" Inherits="DOM.jstable" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function createtable1()
{
var tablenode = document.createElement('table');
//设置表格属性
tablenode.setAttribute('border', '1px');
tablenode.setAttribute('width', '500px');
tablenode.setAttribute('height', '100px');
//创建第一行
tablenode.insertRow(0);
tablenode.rows[0].insertCell(0);
tablenode.rows[0].insertCell(1);
tablenode.rows[0].insertCell(2);
tablenode.rows[0].cells[0].appendChild(document.createTextNode('姓名'));
tablenode.rows[0].cells[1].appendChild(document.createTextNode('旅游地点'));
tablenode.rows[0].cells[2].appendChild(document.createTextNode('出发日期'));
//创建第二行
tablenode.insertRow(1);
tablenode.rows[1].insertCell(0);
tablenode.rows[1].insertCell(1);
tablenode.rows[1].insertCell(2);
tablenode.rows[1].cells[0].appendChild(document.createTextNode('刘能'));
tablenode.rows[1].cells[1].appendChild(document.createTextNode('象牙山'));
tablenode.rows[1].cells[2].appendChild(document.createTextNode('2013-11-11'));
//创建第三行
tablenode.insertRow(2);
tablenode.rows[2].insertCell(0);
tablenode.rows[2].insertCell(1);
tablenode.rows[2].insertCell(2);
tablenode.rows[2].cells[0].appendChild(document.createTextNode('谢娜'));
tablenode.rows[2].cells[1].appendChild(document.createTextNode(' 马栏山'));
tablenode.rows[2].cells[2].appendChild(document.createTextNode('2013-10-10'));
var divnode = document.getElementById('mydiv');
divnode.appendChild(tablenode);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="mydiv">
<input id="Button1" type="button" value="button" onclick="createtable1()"/>
</div>
</form>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function createtable1()
{
var tablenode = document.createElement('table');
//设置表格属性
tablenode.setAttribute('border', '1px');
tablenode.setAttribute('width', '500px');
tablenode.setAttribute('height', '100px');
//创建第一行
tablenode.insertRow(0);
tablenode.rows[0].insertCell(0);
tablenode.rows[0].insertCell(1);
tablenode.rows[0].insertCell(2);
tablenode.rows[0].cells[0].appendChild(document.createTextNode('姓名'));
tablenode.rows[0].cells[1].appendChild(document.createTextNode('旅游地点'));
tablenode.rows[0].cells[2].appendChild(document.createTextNode('出发日期'));
//创建第二行
tablenode.insertRow(1);
tablenode.rows[1].insertCell(0);
tablenode.rows[1].insertCell(1);
tablenode.rows[1].insertCell(2);
tablenode.rows[1].cells[0].appendChild(document.createTextNode('刘能'));
tablenode.rows[1].cells[1].appendChild(document.createTextNode('象牙山'));
tablenode.rows[1].cells[2].appendChild(document.createTextNode('2013-11-11'));
//创建第三行
tablenode.insertRow(2);
tablenode.rows[2].insertCell(0);
tablenode.rows[2].insertCell(1);
tablenode.rows[2].insertCell(2);
tablenode.rows[2].cells[0].appendChild(document.createTextNode('谢娜'));
tablenode.rows[2].cells[1].appendChild(document.createTextNode(' 马栏山'));
tablenode.rows[2].cells[2].appendChild(document.createTextNode('2013-10-10'));
var divnode = document.getElementById('mydiv');
divnode.appendChild(tablenode);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="mydiv">
<input id="Button1" type="button" value="button" onclick="createtable1()"/>
</div>
</form>
</body>
</html>
相关文章推荐
- js 链接地址验证
- 各种javascript框架
- JS事件大全
- extjs 怎么查看属性
- javascript实现的棋牌类
- Js封装html的一些代码
- pager-taglib的使用(jsp分页)
- Javascript调用MsRdpClient 完成Web调用远程桌面
- javascript设置金额样式转换保留两位小数示例代码
- JS获得QQ号码的昵称,头像,生日的简单实例
- JavaScript执行顺序详细介绍
- js中把new Date().getTime()时间戳转化成日期类型
- 2013.12.04 JS实现单元格的合并
- 深入理解JavaScript中的this关键字
- 浏览器图片选择预览、旋转、批量上传的JS代码实现
- c#和JS数据加密
- 两个数组去重的JS代码
- javascript实现信息的显示和隐藏如注册页面
- json格式化工具
- Extjs4 页数重置