What is the usage of confirm in javascript

WBOY
Release: 2021-12-28 19:04:51
Original
10460 people have browsed it

In JavaScript, the confirm() method is used to display a specified message and a dialog box with confirmation and cancellation. The syntax is "confirm (text displayed on the dialog box)". When "OK" is clicked It will return true when the button is clicked, and false when the "Cancel" button is clicked.

What is the usage of confirm in javascript

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

What is the usage of confirm in javascript

This method is a native method of JavaScript, used to display a specified message and confirm and cancel dialog box (the display mode is similar to the alert() effect). When the OK button is clicked (or the Enter key is clicked), true will be returned, and false will be returned when Cancel (or the ESC key) is clicked

<button id="cfm">Confirm测试</button>
<script>
    document.getElementById(&#39;cfm&#39;).onclick = () => {        var test = confirm(&#39;测试&#39;);
        console.log(test)
    }</script>
Copy after login

What is the usage of confirm in javascript

Returns true after clicking OK (or pressing the Enter key)

What is the usage of confirm in javascript

Returns false after clicking Cancel (or the ESC key)

What is the usage of confirm in javascript

[Related recommendations: javascript learning tutorial]

The above is the detailed content of What is the usage of confirm in javascript. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!