JavaScript Reference/Javascript Methods/deleteRow

Материал из Web эксперт
Версия от 18:30, 25 мая 2010; (обсуждение)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"deleteRow()" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
    document.all.myT.deleteRow(2);
}
</script>
<table id="myT" width="25%" border="1">
    <tr>
        <td>Row 1</td>
        <td>Cell 1</td>
    </tr>
    <tr>
        <td>Row 2</td>
        <td>Cell 2</td>
    </tr>
    <tr>
        <td>Row 3</td>
        <td>Cell 3</td>
    </tr>
    <tr>
        <td>Row 4</td>
        <td>Cell 4</td>
    </tr>
</table>
<input type="button" value="Remove Row 3" onclick="function1();">
</body>
</html>



"deleteRow()" is applied to

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



"deleteRow()" Syntax, Parameters and Note

Note:
Deletes a row from the rows collection, or 
from a <table>, <tbody>, <tfoot>, or <thead> element.
    
Syntax:
    
document.all.tableID.rows[index].deleteRow(param1)
document.getElementById("elementID").deleteRow(param1)
document.all.elementID.deleteRow(param1) // IE only

Parameters:
    param1   Optional; the row index in the rows collection. 
                       If omitted, the last row will be removed.