Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 570 Bytes

File metadata and controls

28 lines (24 loc) · 570 Bytes

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)
        }
    })
})