• #Copy Text

    Copy from an input

    textarea.select(); 
    document.execCommand('copy');
    

    Copy from a node

    const selection = window.getSelection();
    const range = document.createRange();
    range.selectNodeContents(ELEMENT);
    selection.removeAllRanges();
    selection.addRange(range);
    
    document.execCommand('copy');
    
    selection.removeAllRanges();
    

    or

    navigator.clipboard.writeText(CONTENT)