How to implement prompt box with javascript
This article mainly introduces the relevant knowledge of "how to use javascript to achieve the prompt box", the editor shows you the operation process through the actual case, the operation method is simple and fast, practical, I hope that this "how to use javascript to achieve the prompt box" article can help you solve the problem.
In JavaScript, you can use the prompt () method of the Window object to implement a prompt box, which pops up to display a prompt box with an input box, a "OK" button, and a "cancel" button with the syntax "prompt (" sometext "," defaultText ").
The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.
How to use javascript to implement prompt box
If you want the user to enter a value before entering the page, you usually use a prompt box.
When the prompt box pops up, the user will have to enter a value and click OK or cancel to continue.
If the user clicks OK, the box returns the input value. If the user clicks cancel, the box returns NULL.
The syntax is:
Window.prompt ("sometext", "defaultText")
The window.prompt () method can be written without the window prefix.
Examples are as follows:
JavaScript Prompt