Related Articles

Related Articles

JQueryUI | dialog
  • Difficulty Level : Medium
  • Last Updated : 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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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=
    </script>
      
    <script src=
    </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>

chevron_right


Output:

Example 2: This example contains button with the close value.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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=
    </script>
      
    <script src=
    </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>

chevron_right


Output:

Supported Browsers: The browsers supported by JQueryUI dialog are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera



My Personal Notes arrow_drop_up
Recommended Articles
Page :