你可以在jquery确认对话框中加粗文字吗?

时间:2013-05-16 19:52:16

标签: jquery html

我有以下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!")});

谢谢!

2 个答案:

答案 0 :(得分:5)

您无法使用标准的javascript弹出窗口执行此操作。

您需要使用自定义库,例如以下某个:

答案 1 :(得分: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>