【问题标题】:New line in Bootbox Alert boxBootbox 警报框中的新行
【发布时间】:2015-07-31 02:28:59
【问题描述】:

我想在我的 Bootbox Alert Box 中创建一个新行。我知道在 Javascript 中你可以使用 \n 但这似乎不起作用。这是我尝试过的:

bootbox.alert("Hello \n world");

【问题讨论】:

  • 您可以添加您已经尝试过的代码吗?
  • 您应该将以下答案标记为已接受,@user3399863。向前支付。 :o)

标签: javascript java twitter-bootstrap


【解决方案1】:

您可以为此使用 html:

bootbox.alert("Hello <br> world!");

会做的

【讨论】:

  • 很明显……但我没想到!谢谢!
【解决方案2】:

带有确认信息

$(function () {
    $(".confirm").click(function (e) {
        e.preventDefault();
        bootbox.confirm({
            message: "<h3>Hello</h3> <br> world!",
            buttons: {
            confirm: {
                label: 'yes',
                className: 'btn-success'
            },
            cancel: {
                label: 'no',
                className: 'btn-danger'
            }
        },
        callback: function (result) {
            if (result)
                console.log('yes');
        }
        });
        
    });
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"></script>

<a href="http://www.example.com/" action="deleteElement" class="btn btn-danger confirm">Delete</a>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多