<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Confirm Box</h2>
<button onclick="myFunction()">Please Try it</button>
<p id="Test Confirm Box"></p>
<script>
function myFunction() {
var txt;
if (confirm("Please Press a button!")) {
txt = "You pressed Button!";
} else {
txt = "You pressed Cancel Button!";
}
document.getElementById("Test Confirm Box").innerHTML = txt;
}
</script>
</body>
</html>
Leave a Reply