Skip to content
Related Articles

Related Articles

jQuery UI Dialog buttons Option
  • Last Updated : 19 Mar, 2021

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 buttons option is used to specify the buttons that should be displayed on the dialog. 

Syntax:

$( ".selector" ).dialog({
  buttons: [
    {
      text: "Ok",
      icon: "ui-icon-heart",
      click: function() {
        $( this ).dialog( "close" );
      }
    }
  ]
});

CDN Link: First, add jQuery UI scripts needed for your project.

<link rel=”stylesheet” href=”//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css”>
<script src=”//code.jquery.com/jquery-1.12.4.js”></script>
<script src=”//code.jquery.com/ui/1.12.1/jquery-ui.js”></script>

Example:



HTML




<!doctype html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <link href=
    rel="stylesheet">
  
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  
    </script>
  
    <script>
        $(function () {
            $("#gfg").dialog({
                autoOpen: false,
                buttons: [
                    {
                        text: "Ok",
                        click: function () {
                            $(this).dialog("close");
                        }
                    }
                ]
            });
            $("#geeks").click(function () {
                $("#gfg").dialog("open");
            });
        });
    </script>
</head>
  
<body style="text-align: center;">
    <h1 style="color:green;">GeeksforGeeks</h1>
    <h3>jQuery UI Dialog buttons Option</h3>
  
    <button id="geeks">Open Dialog</button>
  
    <div id="gfg" title="GeeksforGeeks">
        Welcome to GeeksforGeeks
    </div>
</body>
  
</html>

Output:

Reference: https://api.jqueryui.com/dialog/#option-buttons

My Personal Notes arrow_drop_up
Recommended Articles
Page :