How to set a prompt box with whether in jquery

WBOY
Release: 2022-06-24 17:02:45
Original
1584 people have browsed it

In jquery, you can use prompt to set a prompt box with whether; when the prompt box appears, the user needs to enter a certain value, and then click the "Confirm" or "Cancel" button to continue the operation. If click If you confirm, the return value will be the entered value. If you click Cancel, the return value will be null, and the syntax is ".prompt("sometext","defaultvalue")".

How to set a prompt box with whether in jquery

The operating environment of this tutorial: windows10 system, jquery3.6.0 version, Dell G3 computer.

How to set a prompt box with whether in jquery

The prompt box is often used to prompt the user to enter a certain value before entering the page.

When the prompt box appears, the user needs to enter a certain value and then click the confirm or cancel button to continue the operation.

If the user clicks to confirm, the return value is the entered value. If the user clicks Cancel, the return value is null.

The syntax is:

.prompt("sometext","defaultvalue");
Copy after login

The example is as follows:

function myFunction(){
var x;
var person=prompt("请输入你的名字","Harry Potter");
if (person!=null && person!=""){
    x="你好 " + person + "! 今天感觉如何?";
    document.getElementById("demo").innerHTML=x;
}
}
Copy after login

Output result:

How to set a prompt box with whether in jquery

Extended knowledge:

Alert boxes

Alert boxes are often used to ensure that users can get certain information.

When the warning box appears, the user needs to click the OK button to continue the operation.

Syntax

.alert("sometext");
Copy after login

How to set a prompt box with whether in jquery

Confirmation box

Confirmation box is usually used to verify whether the user operation is accepted.

When the confirmation box pops up, the user can click "Confirm" or "Cancel" to confirm the user operation.

When you click "Confirm", the confirmation box returns true. If you click "Cancel", the confirmation box returns false.

Grammar

.confirm("sometext");
Copy after login

How to set a prompt box with whether in jquery

Video tutorial recommendation: jQuery video tutorial

The above is the detailed content of How to set a prompt box with whether in jquery. 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!