CoPY to CLIPBOARD in JavaScript !
Nischal Dahal
Posted on May 27, 2022
Copy using javascript in proper way !
function copyme(e) {
e = e || window.event;
let target = e.target || e.srcElement;
// const text = target.previousElementSibling.innerHTML;
let text = e.target.value; // getting directly from input element
const el =
document.createElement('textarea');
el.value = text;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}
💖 💪 🙅 🚩
Nischal Dahal
Posted on May 27, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.