Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass HTML code as text of sweet alert

Tags:

sweetalert

I am using this in my application. I would like to use sweet alert like below.

swal({
    title: "Are you sure?",
    text: "You are going to delete <b>"+ name +"</b> address. ",
    icon: "warning",
    buttons: true,
    dangerMode: true,
   })

But it now working. It is displaying HTML code. Thanks.

Update

I read this question, but this question is about sweet alert2. My question is about sweet alert . Both are sweet alert but both are not same.

like image 227
abu abu Avatar asked Dec 11 '22 07:12

abu abu


1 Answers

As @Elnoor has mentioned you can try to use html, but I had a problem in SWAL2 with it so I have used the innerHTML. Like :

 var myhtml = document.createElement("div");
 myhtml.innerHTML = "You are going to delete <b>"+ name +"</b> address. ";

And then put it in your content in swal like :

swal({
    title: "Are you sure?",
    content: myhtml,
    icon: "warning",
    buttons: true,
    dangerMode: true,
   })

Mark that i changed text tag to content tag.

like image 190
SupremeDEV Avatar answered Dec 12 '22 20:12

SupremeDEV