Home >Web Front-end >JS Tutorial >layer.prompt function
layer.prompt is a JavaScript function, usually used to display a dialog box in a web page, prompting the user to enter information or make a choice. The syntax is "layer.prompt(options, callback);". Its functions are The following two points: 1. Display a user input dialog box, which can be used to obtain the text or selection entered by the user; 2. It can be used in various interactive scenarios, such as popping up a confirmation box, entering user name and password, etc.
layer.prompt is a JavaScript function that is usually used to display a dialog box in a web page to prompt the user to enter information or make a selection. Its usage and function are as follows:
Usage:
layer.prompt(options, callback);
Parameter description:
Function:
Sample code:
layer.prompt({title: '请输入您的姓名:'}, function(value, index, elem) { console.log('您输入的姓名是:' + value); layer.close(index); // 关闭对话框 });
The above is a simple example that displays a dialog box with a text input box. After the user enters the name, the value will be output to the callback function through the callback function. console and close the dialog box.
Please note that layer.prompt is a function based on the Layer pop-up plug-in, and the relevant Layer library files need to be introduced into the web page for normal use. For specific usage methods, please refer to the official documentation or related tutorials of the Layer plug-in.
The above is the detailed content of layer.prompt function. For more information, please follow other related articles on the PHP Chinese website!