在JavaScript中,常用Array来存储和 *** 作对象:
Array:
新建:var ary = new Array()或 var ary = []
增加:ary.push(value)
删除:delete ary[n]
遍历:for ( var i=0 i <ary.length ++i ) ary[i]
<!DOCTYPE HTML><html>
<head>
<meta charset="UTF-8" />
<title>last.html</title>
<style type="text/css">
table {
border: 1px solid black
border-collapse: collapse
}
td {
border: 1px solid black
}
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
function initTr ()
{
var $trr = $("<tr style='height:30px'></tr>")
for ( var x = 0 x < 10 x++)
{
var $tdd = "<td>123</td>"
$trr.append ($tdd)
}
$ ("#dataTb>tbody").append ($trr)
}
</script>
</head>
<body>
<input type="button" value="按钮" onclick="initTr()" />
<table class="table" id="dataTb" border="1">
<tbody>
</tbody>
</table>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)