Rasi
answered May 1 '23 00:00
you can create an alert with multiple options using the window.confirm() method . This method displays a modal dialog box with a message and two buttons, usually labeled "OK" and "Cancel".
Here is an example:
var result = window.confirm("Do you want to proceed?");
if (result) {
// user clicked "OK"
console.log("You clicked OK");
} else {
// user clicked "Cancel"
console.log("You clicked Cancel");
}
In this example, window.confirm() displays a dialog box with the message "Do you want to proceed?" and two buttons labeled "OK" and "Cancel". If the user clicks "OK", the window.confirm() method returns true and the code inside the if statement is executed. If the user clicks "Cancel", the method returns false and the code inside the else statement is executed.