编程语言
首页 > 编程语言> > javascript – Sweet alert html选项

javascript – Sweet alert html选项

作者:互联网

我正在尝试使用html选项发出甜蜜警报:

swal({  
   title: "HTML <small>Title</small>!",  
   text: "A custom <span style="color:#F8BB86">html<span> message.",   
   html: true 
});

但是没有那个文字放一个按钮,我试过这个:

var boton = "button";
swal({   
    title: "HTML <small>Title</small>!",  
    text: "<input type=" + boton + ">",  
    html: true 
});

但它不起作用!
(我想制作带有选项的菜单(按钮))
有谁知道怎么做那样的事情?
谢谢!

解决方法:

您可以使用按钮标记而不是输入.

像这样:

var boton = "button";
swal({   
    title: "HTML <small>Title</small>!",  
    text: '<button type="' + boton + '">Button</button>',
    html: true 
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>

标签:javascript,css,html,sweetalert
来源: https://codeday.me/bug/20190516/1116117.html