using dom to copy and paste
function copy() { var copyText = document.querySelector("#input"); copyText.select(); document.execCommand("copy"); } document.querySelector("#copy").addEventListener("click", copy);
copy to clipboard javascript dom
navigator.clipboard.writeText('Text');