📚Cheatsheets

Cheatsheet collection for go, rust, python, shell and javascript.

JavaScript copy to to clipboard

Copy using clipboard.

function copyTextToClipboard(selector) {
    const text = document.querySelector(selector).innerText;
    window.navigator.clipboard.writeText(text).then(() => {
        console.log("done")
    }, (err) => {
        console.log("Got error", err)
    })
}

Usage:

copyTextToClipboard(".content")