JQueryUI | dialog - GeeksforGeeks

31 Oct, 2019
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.
<!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.
<!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
jQuery-Methods
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
Scroll to the top of the page using JavaScript/jQuery
jQuery | children() with Examples
How to get the ID of the clicked button using JavaScript / jQuery ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript