JSFiddle - React, Tailwind, and code Playground
HTML
<button onclick="myFunction()">Try it</button>
<p><span id="rslt"></span></p>
<style>
#rslt
{
border: 1px solid red;
}
}
</style>
<script>
function myFunction() {
let prompt = "Press a button!\nEither OK or Cancel.";
let text= 'uninit'
if (confirm(prompt) == true) {
text = "You pressed OK!";
} else {
text = "You canceled!";
}
document.getElementById("rslt").innerHTML = text;
}
</script>