博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SweetAlert插件
阅读量:2387 次
发布时间:2019-05-10

本文共 1052 字,大约阅读时间需要 3 分钟。

SweetAlert是一个JS插件,能够完美替代JS自带的alert弹出框,并且功能强大,设计优美。

  • 引入文件

<link href="${ctx }/libs/sweetalert/sweetalert.css" rel="stylesheet" type="text/css">

<script src="${ctx }/libs/sweetalert/sweetalert.min.js" type="text/javascript"></script>

  • JS代码

      buttons: {

        "提交": function() {
        //使用sweetAlert插件
        swal({
        title:"您确定要提交吗",
                       text:"提交后将无法恢复,请谨慎操作!",
                       type:"warning",
                       showCancelButton:true,
                       confirmButtonText:"提交",
                       cancelButtonText:"取消",
                       closeOnConfirm:false,
                       closeOnCancel:false
               },
                   function(isConfirm){
                       if(isConfirm){
                           swal({
                            title:"提交成功!",
                               text:"您已经成功提交。",
                               type:"success"
                           },
                                function(){
                                //两种提交方式都可以
                                //document.forms[0].submit();
                                document.getElementById('inputForm').submit();
                                $("#dialog-form").dialog( "close" );
                           });
                       }else{
                           swal({
                            title:"已取消",
                               text:"您取消了本次操作!",
                               type:"error"
                          },
                          function(){
                          $("#dialog-form").dialog( "close" );
                          });
                       }
                   });
                //不能写在这里,可能表单还没提交操作,就已经关闭了
                //$("#dialog-form").dialog( "close" );
       },
       "取消": function() {
          $(this).dialog("close");
       }

效果如下

提交操作

取消操作

参考地址

http://blog.csdn.net/Ayhan_huang/article/details/77365576

http://www.cnblogs.com/beiz/p/5238124.html

你可能感兴趣的文章
FCKeditor本地test.html
查看>>
Hijacking SSH Agents
查看>>
PHP CGI Argument Injection
查看>>
sgx模拟器
查看>>
SGX相关资源
查看>>
nessus 购买地址
查看>>
Apache Kafka desrialization vulnerability via runtime
查看>>
It Takes Two to Tango (myself, and your unprotected file share)
查看>>
From LOW to PWNED [3] JBoss/Tomcat server-status
查看>>
Bypassing HTTP Basic Authentication in PHP Applications
查看>>
测试两台服务器之间的网络带宽
查看>>
误删Oracle数据文件的恢复方法
查看>>
NGS00138 Technical Advisory: Websense Triton 7.6 - authentication bypass in report management UI
查看>>
linux privileged and arbitrary chdir() (fixed at 5.4 cifs release)
查看>>
thinkphp任意代码执行漏洞
查看>>
BackTrack5漏洞评估之OpenVAS(Open Vulnerability Assessment System)
查看>>
cenos 安装openvas
查看>>
Web Application Penetration testing with Google Chrome Browser
查看>>
MS12-032 - Vulnerability in TCP/IP Could Allow Elevation of Privilege
查看>>
Vulnerability Assessment - Information Assurance Tools Report
查看>>