insertCell()

王朝百科·作者佚名  2010-02-21  
宽屏版  字体: |||超大  

Definition and Usage

定义与用法

The insertCell() method is used to insert a new table cell in a table row.

insertCell()方法可用来往表格行中插入新的表格单元

Syntax 语法

tablerowObject.insertCell(index)

--------------------------------------------------------------------------------

Example 举例

<html>

<head>

<script type="text/javascript">

function insRow()

{

var x=document.getElementById('myTable').insertRow(0)

var y=x.insertCell(0)

var z=x.insertCell(1)

y.innerHTML="NEW CELL1"

z.innerHTML="NEW CELL2"

}

</script>

</head>

<body>

<table id="myTable" border="1">

<tr>

<td>Row1 cell1</td>

<td>Row1 cell2</td>

</tr>

<tr>

<td>Row2 cell1</td>

<td>Row2 cell2</td>

</tr>

<tr>

<td>Row3 cell1</td>

<td>Row3 cell2</td>

</tr>

</table>

<form>

<input type="button" onclick="insRow()"

value="Insert row">

</form>

</body>

</html>

 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝百科 版权所有