如何在jQuery的模态对话框的按钮之间放置文本

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

本文关键字:按钮 之间 置文本 对话框 模态 jQuery      更新时间:2023-09-26

我想在按钮"Login"answers"Sign_Up"之间使用jQuery的模态dailog框。怎么做呢?并且,我如何将一些锚标签与这些按钮链接起来?下面是我的代码片段:如有任何帮助,不胜感激,谢谢。

<!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>

您可以尝试添加自定义按钮并根据您的需要更改其样式。代码:

链接: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" />