I would like to make a new line in my Bootbox Alert Box. I know in Javascript you can use \n
but this doesn't seem to work. Here is what I have tried:
bootbox.alert("Hello \n world");
To add a new line to the content of alert box we are going to use \n backslash(n).
The solution, which uses closeButton: false , is seen in the snippet below: bootbox. dialog({ closeButton: false, title: "Woah this acts like an alert", message: "Cool info for you. You MUST click Ok.", buttons: { success:{ label: "Ok", callback: callback } } }); callback(){//stuff that happens when they click Ok.}
Pressing the ESC key or clicking close () dismisses the dialog and invokes the callback as if the user had clicked the Cancel button. Confirm dialogs require a callback function.
js is a small JavaScript library which allows you to create programmatic dialog boxes using Bootstrap modals, without having to worry about creating, managing, or removing any of the required DOM elements or JavaScript event handlers. npm i bootbox • cdnjs.
You can use html for that:
bootbox.alert("Hello <br> world!");
Will do it
with confirm message
$(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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With