I believe many friends will know the meaning of confirm when they see the title. The confirm() method is used to display a dialog box with a specified message and OK and Cancel buttons, but there are still many friends who don’t know, so today we Let me introduce to you the use of confirm() method in JavaScript!
If the user clicks the OK button, confirm() returns true. If the cancel button is clicked, confirm() returns false.
It will block all user input to the browser until the user clicks the OK button or the Cancel button to close the dialog box. When confirm() is called, execution of the JavaScript code is paused and the next statement is not executed until the user responds.
Let’s learn how to use it through these two small examples:
The code is as follows:
Summary :
confirm() is used by us for a better user experience. I believe that friends can further understand the use of confirm() by studying this article. I hope Helpful for your work!
Related recommendations:
JavaScript’s three message boxes alert, confirm, prompt
js-confirm-Confirm cancellation dialog box
js confirm function deletion prompt_PHP tutorial
The above is the detailed content of Introduction to the use of confirm() method in JavaScript. For more information, please follow other related articles on the PHP Chinese website!