作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我未能获得甜蜜的警报,我认为这与语法有关。有人可以告诉我我应该做什么
<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
<script src="dist/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="dist/sweetalert.css">
</head>
<body>
<script>
swal({
title: 'Confirm',
text: 'Are you sure to delete this message?',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, sir',
cancelButtonText: 'Not at all'
});
</script>
</body>
</html>
最佳答案
在 html 中添加一个按钮并触发 onclick 事件。
例如使用标准查询选择器
document.querySelector('button#test-1').onclick = function(){
swal({
title: 'Confirm',
text: 'Are you sure to delete this message?',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, sir',
cancelButtonText: 'Not at all'
});
};
<link href="http://t4t5.github.io/sweetalert/dist/sweetalert.css" rel="stylesheet"/>
<script src="http://t4t5.github.io/sweetalert/dist/sweetalert.min.js"></script>
<button id="test-1">Show alert</button>
关于javascript - 甜蜜警报语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32986381/
我是一名优秀的程序员,十分优秀!