Baseline Widely available
HTMLTableRowElement.insertCell()
ã¡ã½ããã¯ãæ°ããã»ã« (<td>
) ã表ã®è¡ (<tr>
) ã«æ¿å
¥ãããã®ã»ã«ã®åç
§ãè¿ãã¾ãã
ã¡ã¢: insertCell()
ã¯ã»ã«ãç´æ¥è¡ã«æ¿å
¥ãã¾ãã Document.createElement()
ã使ç¨ãã¦æ°ãã <td>
è¦ç´ ã使ããå ´åã®ããã«ã Node.appendChild()
ã使ç¨ãã¦åå¥ã«ã»ã«ã追å ããå¿
è¦ã¯ããã¾ããã
ãã ãã insertCell()
ã使ç¨ãã¦æ°ãã <th>
è¦ç´ ã使ãããã¨ã¯ã§ãã¾ããã
insertCell()
insertCell(index)
HTMLTableRowElement
㯠HTML 㮠<tr>
è¦ç´ ã¸ã®åç
§ã§ãã
index
çç¥å¯
æ°ããã»ã«ã®ä½ç½®ãæå®ãã¾ãã index
ã -1
ã¾ãã¯ã»ã«æ°ã¨çããå ´åããã®ã»ã«ã¯è¡ã®æå¾ã®ã»ã«ã¨ãã¦è¿½å ããã¾ãã index
ãçç¥ãããå ´åã¯ãæ¢å®ã§ -1
ã¨ãªãã¾ãã
HTMLTableCellElement
ã§ãæ°ããã»ã«ã¸ã®åç
§ã§ãã
IndexSizeError
DOMException
index
ãã»ã«æ°ããã大ããå ´åã«çºçãã¾ãã
ãã®ä¾ã§ã¯ã HTMLTableElement.insertRow()
ã使ç¨ãã¦è¡¨ã«æ°ããè¡ã追å ãã¾ãã
ãããã insertCell(0)
ã使ç¨ãã¦ãæ°ããã»ã«ãæ°ããè¡ã«è¿½å ãã¾ããï¼æå¹ãª HTML ã«ããããã«ã¯ã <tr>
㯠1 ã¤ä»¥ä¸ã® <td>
è¦ç´ ãæã¤å¿
è¦ãããã¾ããï¼æå¾ã«ã Document.createTextNode()
㨠Node.appendChild()
ã使ç¨ãã¦ããããã®ããã¹ãã追å ãã¾ãã
<table id="my-table">
<tr>
<td>è¡ 1</td>
</tr>
<tr>
<td>è¡ 2</td>
</tr>
<tr>
<td>è¡ 3</td>
</tr>
</table>
JavaScript
function addRow(tableID) {
// 表ã¸ã®åç
§ãåå¾
let tableRef = document.getElementById(tableID);
// è¡¨ã®æ«å°¾ã«è¡ã追å
let newRow = tableRef.insertRow(-1);
// è¡ã® 0 ã®ä½ç½®ã«ã»ã«ã追å
let newCell = newRow.insertCell(0);
// ã»ã«ã«ããã¹ããã¼ãã追å
let newText = document.createTextNode("æ°ããæä¸è¡");
newCell.appendChild(newText);
}
// addRow() ã表㮠ID ã§å¼ã³åºã
addRow("my-table");
çµæ 仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4