1

我有以下 jquery 代码:

<script type="text/javascript">
        $(document).ready(function() {
        $(".deleteuser").click(function(){ return confirm("Are you sure you want to delete this user?")});
        });
</script>

我希望能够将确认对话框中的文本加粗......就像这样:(伪代码)

$(".deleteuser").click(function(){ return confirm("Are you sure you want to delete this user? <b>Note:</b> It can't be undone!")});

谢谢!

4

2 回答 2

5

您不能使用标准的 javascript 弹出窗口来执行此操作。

您需要使用自定义库,例如以下之一:

于 2013-05-16T19:54:48.090 回答
0

从http://jqueryui.com/dialog/试试这个例子:

<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Basic modal</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>

$(function() {
    $( "#dialog-confirm" ).dialog({
        resizable: false,
        autoOpen: false,
        modal: true,
        buttons: {
            "Delete all items": function() {
                $( this ).dialog( "close" );
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        }
    });
    $( "#opener" ).click(function() {
        $( "#dialog-confirm" ).dialog( "open" );
    });
});


</script>
</head>
<body>
<div id="dialog-confirm" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
<button id="opener">Delete user</button>

</body>
</html>
于 2013-05-16T20:32:18.020 回答