JavaScript Reference/Javascript Methods/insertRow

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

"insertRow()" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> function function1() {

  var myRow = document.all.myTable.insertRow();
  var myCell = myRow.insertCell();
  myCell.innerText = "The added cell"; 

} </script>

3 4
1 2

<button onclick="function1();">Add a cell</button> </body> </html>


     </source>
   
  


"insertRow()" is applied to

   <source lang="javascript">

Names noted with an asterisk (*) are JavaScript properties only. +----------------+--------------------------------------------------------------+

| Applied_To |rows* | | |<tbody> <tfoot> | | |<thead> | +----------------+--------------------------------------------------------------+ </source>

"insertRow()" Syntax, Parameters and Note

   <source lang="javascript">

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.
   
     
</source>