简体   繁体   中英

How to put a text in between the buttons inside a modal dialog box in jQuery?

I want to put a text in between the buttons "Login" and "Sign_Up" inside the modal dailog box using jQuery. How to do it? And , How can I link some anchor tags with those buttons? Here is my snippet of code: Any help will be much appreciated , Thanks.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog - Default functionality</title>

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/ui-darkness/jquery-ui.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>



<script type="text/javascript">

    $(function () {
        $("#dialog_nav").dialog({
            autoOpen: false,
            modal: true,
            dialogClass: "First_Dialog",
            resizable: false,
            buttons: {
                "Login": function () {
                    $(this).dialog("close");
                },
                "SignUp": function () {
                    $(this).dialog("close");
                }
            }
        });

        $("#Dialog_Modal").on("click", function (event) {
            $("#dialog_nav").dialog("open");
        });

});



</script>


<style type="text/css">
    .First_Dialog .ui-dialog-titlebar{
        display:none;
}
    .First_Dialog .ui-dialog-titlebar-close{
        display:none;
}
</style>

</head>
<body>

<div id="dialog_nav" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div> 
<input type="button" id="Dialog_Modal" value="Click to open a modeless dialog" /> 
</body>
</html>

You can try adding a custom button and changing it's style according to your needs. Code:

Link : http://jsfiddle.net/lotusgodkk/GCu2D/69/

Javascript:

$(function () {
    $("#dialog_nav").dialog({
        autoOpen: false,
        modal: true,
        dialogClass: "First_Dialog",
        resizable: false,
        buttons: [{
            text: "Cancel",
                "class": 'cancelButtonClass',
            click: function () {
                // Cancel code here
            }
        }, {
            text: "Custom",
                "class": 'custom',
            click: function () {
                //  code here
            }
        }, {
            text: "Cancel",
                "class": 'cancelButtonClass',
            click: function () {
                // Cancel code here
            }
        }, ],
    });

    $("#Dialog_Modal").on("click", function (event) {
        $("#dialog_nav").dialog("open");
    });
});

HTML:

<div id="dialog_nav" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<input type="button" id="Dialog_Modal" value="Click to open a modeless dialog" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM