I am using sweet-alert plugin to display an alert. With a classical config (defaults), everything goes OK. But when I want to add a HTML tag into the TEXT, it display <b>...</b>
without making it bold. After searching for the answer, it looks like I don't have the right search word...
How to make sweet alert display the text also with HTML code?
var hh = "<b>test</b>";
swal({
title: "" + txt + "",
text: "Testno sporocilo za objekt " + hh + "",
confirmButtonText: "V redu",
allowOutsideClick: "true"
});
I just applied the patch above and it starts working.
Sweet alerts also has an 'html' option, set it to true.
A feature to allow HTML for title and text parameters has been added with a recent merge into the master branch on GitHub https://github.com/t4t5/sweetalert/commit/9c3bcc5cb75e598d6faaa37353ecd84937770f3d
Simply use JSON configuration and set 'html' to true, eg:
This was merged less than a week ago and is hinted at in the README.md (html is set to false in one of the examples although not explicitly described) however it is not yet documented on the marketing page http://tristanedwards.me/sweetalert
I just struggled with this. I upgraded from sweetalert 1 -> 2. This library: https://sweetalert.js.org/guides/
The example from documentation "string" doesn't work as I expected. You just can't put it like this.
How I solved it:
There is no documentation how to do this, it was pure trial and error, but at least seems to work.
Use SweetAlert's
html
setting.You can set output html direct to this option:
Or
I assume that
</
is not accepted inside the string.Try to escape the forward slash "/" by preceding it with a backward slash "\" for example: