The Dialog box is the way to inform the user about something. It is a nice way to popup on the user window to show the information that will happen in the next or any kind of information developer wants to clarify to the user should know. jQueryUI dialog method is used to create a basic dialog window inside the page. It has a title bar and a content area and can be moved, resized and closed with the 'X' icon by default.
Syntax:
$(selector, context).dialog(options)
Note: We can customize the dialog box bypassing various options inside the dialog function in the code. If there is more than one option, we can pass them by using comma-separated. We can add certain functionalities to it in the following manner.
$(selector, context).dialog({option1: value1, option2: value2... })
Parameters: There is a single parameter accepted by jQuery dialog mentioned above and described below:
- options: This parameter is an object that specifies the appearance and behavior of the window.
Below examples illustrate the
jQueryUI dialog.
Example 1: This example does not contain button with the blank option.
html
<!DOCTYPE html>
<html>
<head>
<title>jQueryUI-Dialog</title>
<link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet"
href="/resources/demos/style.css">
<script src=
"https://code.jquery.com/jquery-1.12.4.js">
</script>
<script src=
"https://code.jquery.com/ui/1.12.1/jquery-ui.js">
</script>
<script>
$(function() {
$("#dialog").dialog();
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<h1 style="color:green;">GeeksforGeeks</h1>
<h4>JQueryUI dialog box</h4>
<p>This is a sample dialog box.</p>
</div>
</body>
</html>
Output:
Example 2: This example contains button with the close value.
html
<!DOCTYPE html>
<html>
<head>
<title>jQueryUI-Dialog</title>
<link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet"
href="/resources/demos/style.css">
<script src=
"https://code.jquery.com/jquery-1.12.4.js">
</script>
<script src=
"https://code.jquery.com/ui/1.12.1/jquery-ui.js">
</script>
<script>
$(function() {
$("#dialog").dialog({
buttons: {
OK: function() {
$(this).dialog("close");
}
},
title: "Dialog box title"
});
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<h1 style="color:green;">GeeksforGeeks</h1>
<h4>JQueryUI dialog box</h4>
<p>A Computer Science Portal for Geeks</p>
</div>
</body>
</html>
Output:
Supported Browsers: The browsers supported by
JQueryUI dialog are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
Similar Reads
jQuery UI Dialog open Event jQuery UI open event is triggered when the dialog box is opened. Syntax: Learn more about jQuery selectors and events here. $(".selector").dialog ( open: function( event, ui ) { console.log('opened') },Approach: First, add jQuery Mobile scripts needed for your project.<link href = "https://code.j
1 min read
jQuery UI Dialog Drag Event jQuery UI Drag event is triggered when the dialog box is dragged. Learn more about jQuery selectors and events here. Syntax: $(".selector").dialog ( drag: function( event, ui ) { console.log('dragged') },Approach: First, add jQuery Mobile scripts needed for your project.<link href = "https://code
1 min read
jQuery UI dialog open() Method open() Method is used to open the dialog. This method does not accept any argument Syntax: $( ".selector" ).dialog("open"); Approach: First, add jQuery UI scripts needed for your project. <link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel = "stylesheet">
1 min read
jQuery UI Dialog focus Event The Dialog box is the way to inform the user about something. It is a nice way to popup on the user window to show the information that will happen in the next or any kind of information the developer wants to clarify to the user should know. jQueryUI dialog method is used to create a basic dialog w
2 min read
jQuery UI Dialog show Option jQuery UI consists of GUI widgets, visual effects, and themes implemented using jQuery, CSS, and HTML. jQuery UI is great for building UI interfaces for the webpages. The jQuery UI Dialog show Option is used to set how to animate the showing of the dialog. This option contains Boolean or Number or S
1 min read