swal弹窗示例

1 篇文章 0 订阅
1 篇文章 0 订阅

以下代码网页中打开即可调试  

<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"  />
    <title>测试页面</title>
    <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.css" />
    <script src="https://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.js"></script>
    <script>/*详解:https://sweetalert.js.org/*/</script>
  </head>
  
  <body>
    <div style="margin: 50px; text-align: center;">
      <input id="alertNoCallBack" type="button" value="提示" />
    </div>
    <div style="margin: 50px; text-align: center;">
      <input id="alertCallBack" type="button" value="提示!" />
    </div>
    <div style="margin: 50px; text-align: center;">
      <input id="confirm" type="button" value="确认" />
    </div>
    <script>
      /*type: {'success', 'warning', 'error','loading'}*/
      function showConfirm(type,info,action,showCancelButton,showConfirmButton){
        swal({
          title: "消息提示",
          text: info,
          type: type,
          showCancelButton: showCancelButton,
          cancelButtonText:"取消",
          cancelButtonColor:"#B9B9B9",
          showConfirmButton: showConfirmButton,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "确认",
          closeOnConfirm:true,
          closeOnCancel:true
        },action);
      };
    </script>
    
    <script>
      function alertNoCallBack(){
        swal("提示","解除失败!","error");
      }
    </script>
    
    <script>
      function alertCallBack(){
        showConfirm("info","喵喵叫!",function(){alert("回调函数!");},false,true)
      }
    </script>

    <script>
      function confirm(){
        showConfirm("success","执行成功!",function(){alert("回调函数!");},true,true)
      }
    </script>
    <script>
      $(function(){
        $("#alertNoCallBack").click(function(){alertNoCallBack();});
        $("#alertCallBack").click(function(){alertCallBack();});
        $("#confirm").click(function(){confirm();});
      });
    </script>
  </body>
</html>

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值