JavaScript Reference/Javascript Methods/insertRow — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:22, 26 мая 2010

"insertRow()" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
   var myRow = document.all.myTable.insertRow();
   var myCell = myRow.insertCell();
   myCell.innerText = "The added cell"; 
} 
</script>
<table id="myTable" border="1" cellspacing="5" cellpadding="5">
   <tr>
       <td width="100">3</td>
       <td width="100">4</td>
   </tr>
   <tr>
       <td>1</td>
       <td>2</td>
   </tr>
</table>
<button onclick="function1();">Add a cell</button>
</body>
</html>



"insertRow()" is applied to

Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_To     |rows*                           <table>                       |
|                |<tbody>                         <tfoot>                       |
|                |<thead>                                                       |
+----------------+--------------------------------------------------------------+



"insertRow()" Syntax, Parameters and Note

Note:
Adds a row to the specified element.
    
Syntax:
    
document.elementID.rows.insertRow(param1)
document.getElementById("elementID").insertRow(param1)
document.all.elementID.insertRow(param1) // IE only

Parameters:
    param1   Optional; the index. 
                       The default value is -1, which appends the new row to the end.