npm.io
0.1.0 • Published 4 years ago

copied

Licence
MIT
Version
0.1.0
Deps
0
Size
2 kB
Vulns
0
Weekly
0

Copied

Copy to clipboard in browser.

npm install copied
import copied from 'copied'
const btn = document.getElementById('btn')

btn.addEventListener('click', () => {
    btn.setAttribute('disabled', "true")
    copied('Hello Text !', (err) => {
        if (err) {
            console.error(err)
        } else {
            console.log('Copied !')
            btn.innerText = 'Copied !'
            setTimeout(() => {
                btn.innerText = 'Copy'
                btn.removeAttribute('disabled')
            }, 500)
        }
    })
})

Keywords