悠悠楠杉
网站页面
SweetAlert使弹出消息变得简单而美观!
CDN js文件(二选一):
1、<script src="https://cdn.jsdelivr.net/npm/sweetalert"></script>
2、<script src="https://unpkg.com/sweetalert@2.1.2/dist/sweetalert.min.js"></script>
下载地址:https://zhizun.lanzoux.com/iPLhIim4bgb
使用方法:
<button class="btn">点击提示框</button>
<script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script src="sweetalert/sweetalert.min.js"></script>
<script>
//swal("Hello world!");//一个参数的是文本
//swal("Here's the title!", "...and here's the text!");//两个参数,第一个将是模态的标题,第二个是文本
//swal("Good job!", "You clicked the button!", "success");//三个参数,您可以在警报中添加一个图标!有4分预定义的: "warning", "error", "success" 和 "info"
$('.btn').on('click',function(){
swal("提示", "操作成功", "success",{
buttons: ["取消","确定"]//,dangerMode: true //确定按钮变红色
}).then((value) => {
// swal(`The returned value is: ${value}`);
if(value){
swal('确定');
}else{
swal('取消');
}
});
})
</script>