I would like to know if I can delay the action of a button in html, so when I click a button, it comes up with an animation or a picture saying; Please Wait... for 1 or 2 seconds, then execute the code? This is a small part of my code that I want to delay;
<button onclick="myFunction()">Summon</button>
<p id="demo"></p>
<script>
function myFunction()
{
var luck= ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16'],
lucknumber = Math.floor((Math.random() * luck.length));
if (lucknumber < 14){
document.getElementById("demo").innerHTML = "SR";
}
else {
document.getElementById("demo").innerHTML = "SSR";
}
}
</script>
Yeah, it's a basic code but I am a beginner, so any answers will be really appreciated! Thank you!