HTMLTableElement: deleteRow() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
構文
js
deleteRow(index)
引数
index
-
index
は整数で、削除する行を表します。 ただし、特殊な値-1
を使用すると、表の最後の行を削除することができます。
返値
なし (undefined
)。
例外
IndexSizeError
DOMException
-
index
が利用可能な行数以上である場合、あるいは負の数で、表の最終行を表す特別な値-1
ではない場合に発生します。
例
この例は、 JavaScript を使用して表の 2 番目の行を削除します。
HTML
html
<table>
<tr>
<td>セル 1.1</td>
<td>セル 1.2</td>
<td>セル 1.3</td>
</tr>
<tr>
<td>セル 2.1</td>
<td>セル 2.2</td>
<td>セル 2.3</td>
</tr>
<tr>
<td>セル 3.1</td>
<td>セル 3.2</td>
<td>セル 3.3</td>
</tr>
</table>
JavaScript
js
let table = document.querySelector("table");
// 2 番目の行を削除
table.deleteRow(1);
結果
仕様書
Specification |
---|
HTML # dom-table-deleterow-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
deleteRow |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.