I saw that you could use the content option, but im not really sure how to go about that right now I have something like:
swal({title: 'hello', text: 'hello ${<strong>{name}</strong>}', icon: 'success' })
I saw that you could use the content option, but im not really sure how to go about that right now I have something like:
swal({title: 'hello', text: 'hello ${<strong>{name}</strong>}', icon: 'success' })
- 4 Try the same way that you used in 2017. It should work. ;) – Ricky Notaro-Garcia Commented Feb 19, 2018 at 18:53
- I tried the html true and all that , but no success – Taylor Austin Commented Feb 19, 2018 at 18:58
2 Answers
Reset to default 8From the GitHub Issues, you should set a content and insert the text within it:
var name = "Stack Overflow";
var content = document.createElement('div');
content.innerHTML = 'Hello <strong>'+ name +'</strong>';
swal({
title: 'Hello',
content: content,
icon: "success",
})
Or, you can use SweetAlert2 - the supported fork of original SweetAlert:
Swal.fire({
html: 'Overengineering is <strong>a bad thing</strong>'
})
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
PS. notice that SweetAlert2 is a little bit different from SweetAlert, check the simple migration guide: https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2