개발모음집

How to copy text without input tag 본문

client

How to copy text without input tag

void 2020. 2. 26. 10:00
  const value = 'copy text';
  const input_temp = document.createElement("input");
  input_temp.value = value;
  document.body.appendChild(input_temp);
  input_temp.select();
  document.execCommand("copy");
  document.body.removeChild(input_temp);

출처 : https://stackoverflow.com/questions/50795042/create-a-copy-button-without-an-input-text-box