teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

insertAdjacentHTML

2021/12/07 07:54

投稿

int32_t
int32_t

スコア21933

answer CHANGED
@@ -7,13 +7,18 @@
7
7
  属性を個別に設定するか、
8
8
 
9
9
  ```js
10
- cell1.dataset.title = 'test';
10
+ cell1.dataset.title = 'test';
11
- cell1.className = 'col-1';
11
+ cell1.className = 'col-1';
12
- cell1.textContent = 'test';
12
+ cell1.textContent = 'test';
13
13
  ```
14
14
 
15
15
  `outerHTML` で `<td>` を入れ替えるとよいでしょう。
16
16
 
17
17
  ```js
18
- cell1.outerHTML = '<td data-title="test" class="col-1">' + 略...
18
+ cell1.outerHTML = '<td data-title="test" class="col-1">' + 略...
19
+ ```
20
+
21
+ `insertCell(-1)` を使わない手もあります。
22
+ ```js
23
+ row.insertAdjacentHTML('beforeend', '<td data-title="test" class="col-1">' + 略...);
19
24
  ```