Click to Copy using JavaScript

Add given code on your website and make copy button for Div Content.

JavaScript Code

// Lyrics Copy Button
var EngCopyLyrics = document.getElementById("EngCopyLyrics");
if(EngCopyLyrics) {
EngCopyLyrics.addEventListener("click", function() {
var elemEng = document.getElementById("spldivPrintLyrics");
var textEnglish = elemEng.innerText;
navigator.clipboard.writeText(textEnglish);
var EngcopyMessage = document.getElementById("EngcopyMessage");
EngcopyMessage.style.display = "inline";
setTimeout(function() {
EngcopyMessage.style.display = "none";
}, 2000);
});
}

Button

<button id="EngCopyLyrics" class="lyricsprintbtn"><i class="fa fa-copy"></i><i id="EngcopyMessage" style="display: none;">Copied</i></button>

Additional Code

You want to add automatically post URL on div’s content when anyone click to copy button. So add one more code on JavaScript

var permalink = "\n\nCopied from TheKroyaard : \n" + window.location;

Full code

// Lyrics Copy Button
var EngCopyLyrics = document.getElementById("EngCopyLyrics");
if(EngCopyLyrics) {
EngCopyLyrics.addEventListener("click", function() {
var elemEng = document.getElementById("spldivPrintLyrics");
var textEnglish = elemEng.innerText;
var permalink = "\n\nCopied from TheKroyaard : \n" + window.location;
navigator.clipboard.writeText(textEnglish + permalink);
var EngcopyMessage = document.getElementById("EngcopyMessage");
EngcopyMessage.style.display = "inline";
setTimeout(function() {
EngcopyMessage.style.display = "none";
}, 2000);
});
}

Hope this code works perfectly on your website.

FAQ

Can use this code on Blogger website?
Yes! use this code on blogger website.