Show Short Message when Click Button | WordPress

When you click on button, And want to show short message but not want to showing alert box. So use given code on your website.

How to Do

  • I share my example code, Hope you can understand and you easily implement with your website’s code . So lets see this-
<i id="HincopyMessage" style="display: none;">☑</i>

<script>var HincopyMessage = document.getElementById("HincopyMessage");
HincopyMessage.style.display = "inline";
setTimeout(function() {
HincopyMessage.style.display = "none";
}, 2000); </script>
  • Now see my full code when click on button.
<button id="EngCopyLyrics" class="lyricsprintbtn">Copy <i id="EngcopyMessage" style="display: none;"><img draggable="false" role="img" class="emoji" alt="☑" src="https://s.w.org/images/core/emoji/14.0.0/svg/2611.svg"></i></button>
<script>
var EngCopyLyrics = document.getElementById("EngCopyLyrics");
if(EngCopyLyrics !=null) {
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);
});
} </script>

I pasted above code. You can change or modify time, icon or id. Hope this code helpful for you.