Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sweet alert shows TRUE instead of alert text

I’m working with Sweet Alert to show some message so I coded this:

$(document).on('click', '#rules', function(e) {
  swal({
    html: true,
    title: '<b>Title</b>',
    text: '<b>Text</b>'
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.slim.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

<button id="rules">Rules</button>

But it shows this:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

However it should be written Text as text!

So what’s going wrong here? How can I solve this issue?

>Solution :

html is not a boolean option, it’s a string of HTML. And in v1 it has been deprecated in favor of content.

So you should write

$(document).on('click', '#rules', function(e) {
     swal({ title:'<b>Title</b>', content:'<b>Text</b>'});
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading