回答編集履歴

2

.

2023/03/13 02:16

投稿

int32_t
int32_t

スコア20884

test CHANGED
@@ -4,5 +4,9 @@
4
4
  cellElem.textContent = 'セル';
5
5
  document.querySelector('#th-3').after(cellElem);
6
6
  ```
7
+ または
8
+ ```js
9
+ document.querySelector('#th-3').insertAdjacentHTML('afterend', '<th>セル</th>');
10
+ ```
7
- でいいのではないでしょうか。
11
+ などでいいのではないでしょうか。
8
12
 

1

.

2023/03/13 01:58

投稿

int32_t
int32_t

スコア20884

test CHANGED
@@ -1,5 +1,7 @@
1
1
  既存の<tr>に追加したいのに `insertRow()` (新たな<tr>を挿入する)はおかしいですね。
2
2
  ```js
3
+ const cellElem = document.createElement('th');
4
+ cellElem.textContent = 'セル';
3
5
  document.querySelector('#th-3').after(cellElem);
4
6
  ```
5
7
  でいいのではないでしょうか。