function copyElementText() {
var elm = document.getElementById("text");
// for Internet Explorer
if (document.body.createTextRange) {
var range = document.body.createTextRange();
range.moveToElementText(elm);
range.select();
document.execCommand("Copy");
$("#copybtn").html("Copied");
setInterval(function () {
popup.classList.add('hide');
}, 500);
} else if (window.getSelection) {
// other browsers
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(elm);
selection.removeAllRanges();
selection.addRange(range);
document.execCommand("Copy");
$("#copybtn").html("Copied");
setInterval(function () {
popup.classList.add('hide');
}, 500);
}
}
Copy to Clipboard JS
