Home > Web Front-end > JS Tutorial > Detailed analysis of the usage of JQUERY dialog_jquery

Detailed analysis of the usage of JQUERY dialog_jquery

WBOY
Release: 2016-05-16 17:08:11
Original
1528 people have browsed it

Today I used client-side dialog boxes and learned about the dialog boxes in jQuery UI.

Prepare jQuery environment

First, we create a button. When this button is clicked, a dialog box will pop up.

In order to set the click event of this button, you need to prepare the jQuery environment.

Set the click event of the button in ready.

Copy code The code is as follows:

$(function() {
// Initialization
$("#btn").click(function() {
alert("btn was clicked!");
}
);

Confirm There is no problem with this step. Prepare the dialog box

The second step is to prepare the content of the dialog box. This content comes from the jQuery UI demo files.

Copy code The code is as follows:

                                                                        ​ ;
These items will be permanently deleted and cannot be recovered. Are you sure?





In order to use jQuery UI dialog box, you need to add references to these files.







Add style
Used in jQuery UI To decorate a large number of styles, you need to reference the styles of jQuery UI. Note that the jquery.ui.all.css file refers to a large number of other style files. Copy the contents of the development-bundlethemesbase folder in jQuery UI.

In the ready function, this dialog box is also initialized.


$(function() {
// Initialization
$("#btn").click(function() {
alert("btn was clicked!");
});

// Initialization dialog box
$("#dialog-confirm").dialog();
});


Now, when you open this page, you can already see the dialog box.

Pop up a dialog box through a buttonWe hope that this dialog box will not be visible when the page is initialized, and will appear again when the button is clicked. Then these tasks are needed.


First add a style to the dialog box that is not displayed by default. style="display: none", so this part will not be seen by default.


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