html之SweetAlert2使用方法集锦(一)
来源:互联网 发布:情侣礼物知乎 编辑:程序博客网 时间:2024/06/05 21:35
方式一:
function check(id) { var serverAddr = 'http://127.0.0.1:8000/app/index.html'; swal({ title: "", text: "确定删除吗?", type: "warning", showCancelButton: "true", showConfirmButton: "true", confirmButtonText: "确定", cancelButtonText: "取消" }, function () { var ids = []; ids.push(id + ""); $.ajax({ type: "post", url: serverAddr, traditional: true, dataType: "json", data: {"id": ids} }).done(function (data) { swal("操作成功!", "已成功删除数据!", "success"); }).error(function (data) { swal("OMG", "删除操作失败了!", "error"); }); }); }
方式二:
$('button').click(function(){ swal({ title: "Are you sure?", text: "You will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonColor: '#DD6B55', confirmButtonText: 'Yes, delete it!', cancelButtonText: "No, cancel plx!", closeOnConfirm: false, closeOnCancel: false //imageUrl: "images/thumbs-up.jpg" 用于替换Title上方的图 }, function(isConfirm){ if (isConfirm){ swal("Deleted!", "Your imaginary file has been deleted!", "success"); } else { swal("Cancelled", "Your imaginary file is safe :)", "error"); } });};
方式三:
<button class="btn btn-danger center" onClick="check({{book.id}})">删除</button> function check(id){ swal( {title:"", text:"", type:"warning", showCancelButton:true, confirmButtonColor:"#DD6B55", confirmButtonText:"", cancelButtonText:"", closeOnConfirm:false, closeOnCancel:false }, function(isConfirm) { if(isConfirm) { swal({title:"删除成功!", text:"", type:"success"},function(){window.location=""+id}) } else{ swal({title:"已取消", text:"", type:"error"}) } } ) }
阅读全文
0 0
- html之SweetAlert2使用方法集锦(一)
- 毕业设计之错误集锦(一)
- 设计模式之问题集锦(一)
- FPGA开发之错误集锦(一)
- HTML之table样式集锦
- android之listview使用方法(一)
- SQLite3使用方法大全(一)之常用命令
- html:radio之五使用方法
- Python集锦(一)
- 前端之HTML面试题集锦
- Qt学习之旅----功能函数集锦(一)
- JavaScript实用技巧集锦(一)
- 精彩SQL集锦(一)
- JavaScript实用技巧集锦 (一)
- C问题集锦(一)
- JavaScript语法集锦(一)
- W5500问题集锦(一)
- 错题集锦(一)
- 值栈(ValueStack)
- 常用排序算法2--归并排序和快速排序
- linux的环境变量
- python网址
- 前端知识体系目录
- html之SweetAlert2使用方法集锦(一)
- Duilib Button属性和HorizontalLayoutUI的扩展
- 美团点评2018笔试编程题
- TimeUtil --- 时间格式化工具
- C语言面向对象之STL库--Vector
- 莫比乌斯反演
- 51例程---跑马灯
- Android TextView中怎么改变某个字体的颜色
- Java内存模型与线程