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

回答編集履歴

1

ちょうせい

2019/11/15 01:53

投稿

yambejp
yambejp

スコア118268

answer CHANGED
@@ -5,11 +5,10 @@
5
5
  document.querySelector('#copy').addEventListener('click',()=>{
6
6
  const ta = Object.assign(document.createElement('textarea'),{
7
7
  textContent:content,
8
- id:'ta',
9
8
  style:'positon:absolute;top:-999px',
10
9
  });
11
10
  document.querySelector('body').appendChild(ta);
12
- document.querySelector('#ta').select();
11
+ ta.select();
13
12
  document.execCommand('copy');
14
13
  document.querySelector('body').removeChild(ta);
15
14
  });