javascript - 甜蜜警报 html 选项

标签 javascript html css sweetalert

我正在尝试使用 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 
});

但是没用! (我想制作一个带有选项(按钮)的菜单) 有人知道怎么做吗? 谢谢!

最佳答案

您可以使用 button 标签代替 input

像这样:

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 - 甜蜜警报 html 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35058635/

相关文章:

javascript - 每次按下按钮时清除 View 并重新开始 - backbone.js

javascript - 使用 javascript 动态设置 div 最大高度

php - 无法弄清楚是什么导致我的网站出现横向滚动

内联样式属性的 CSS 选择器同时排除属性值

javascript - 处理表单后更改 onclick 函数的位置

javascript - 如何使用 Vue.js 2 中的事件总线通过自定义事件传递数据

javascript - JS/HTML - 单页应用程序 - 取消异步操作

ios - History API 在 iOS 上损坏了吗? (位置栏不会在 pushState 上更新)

html - Css 未添加到在 IE 中动态加载的内容

css - 图像悬停和转换问题