1.swal()方法中的参数:

2.引入css与js,通过cdn加速服务

<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css" rel="stylesheet">

<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>

3.常用

1.

swal("Pikachu fainted! You gained 500 XP!");

2.

swal({
title : "支付成功",
type : "success",
confirmButtonText : "确定",
closeOnConfirm : false
});

结果

 3.

swal("删除失败","重新操作",'error');

  效果:

 4.

                                swal({
title:'',
text:"请扫描用户手机上的付款码",
type:'input',
showCancelButton: true,
closeOnConfirm: false,
cancelButtonText: "取 消",
confirmButtonText: "确 认",
imageUrl:'../../../../img/scancode.gif',
inputPlaceholder:"请填写付款码数字",
showLoaderOnConfirm:true
})

  运行结果

5.

swal({
title:"是否删除",
text:"",
type:"warning",
showCancelButton:true,//是否显示取消按钮
cancelButtonText:'取 消',//按钮内容
cancelButtonColor:'#b9b9b9', showConfirmButton:true,
confirmButtonText:'确 认',
confirmButtonColor:"#dd6b55", closeOnConfirm:false,//点击返回上一步操作
closeOnCancel:true
},function(){//正确按钮进行的操作点
$.ajax({
url: './test.json',
type: 'post',
dataType: 'json',
data: {"id": $('#inp').val()},
})
.done(function(res) {
if (!$('#inp').val()) {
swal("输入内容哦……");
return;
}
if (res.status == '000') {
swal('删除成功','请继续操作','success');
return;
}else{
swal('删除失败','','error');
}
// console.log("success");
})
.fail(function() {//连接服务器失败进行的操作
console.log("error");
})
.always(function() {
console.log("complete");
}); });

  

6.确认输入

swal({
title:'',
text:"请扫描用户手机上的付款码",
type:'input',
showCancelButton: true,
closeOnConfirm: false,
cancelButtonText: "取 消",
confirmButtonText: "确 认",
imageUrl:'../../../../img/scancode.gif',
inputPlaceholder:"请填写付款码数字",
showLoaderOnConfirm:true
},function(inputValue){
if (inputValue == '') {
swal.showInputError('请填写付款码数字');
return;
}
if (inputValue == false) {
swal('','','success');
return;
} swal('ok');
});

  效果:

官网:http://www.dglives.com/demo/sweetalert-master/example/

sweetalert的使用的更多相关文章

  1. zTree和SweetAlert插件初探

    1.zTree插件简介 zTree是一个依靠 jQuery实现的多功能“树插件”.优异的性能.灵活的配置.多种功能的组合是zTree最大优点.专门适合项目开发,尤其是树状菜单.树状数据的Web显示.权 ...

  2. sweetalert api中文开发文档和手册

    官网和下载地址: http://t4t5.github.io/sweetalert/  2016年10月30日14:10:21 废话,目前php开发越来越API话,所以php方法很多都是json返回数 ...

  3. 很漂亮的SweetAlert.js 弹出层

    在线实例 实例演示 使用方法 swal("Here's a message!") 复制 参数详解 参数 默认值 描述 title null(required) 窗口的名称.可以通过 ...

  4. SweetAlert – 替代 Alert 的漂亮的提示效果

    Sweet Alert 是一个替代传统的 JavaScript Alert 的漂亮提示效果.SweetAlert 自动居中对齐在页面中央,不管您使用的是台式电脑,手机或平板电脑看起来效果都很棒.另外提 ...

  5. 弹出框三 之 sweetalert

    1下载sweetalert 2.引入到项目中 <link href="~/Content/sweetalert.css" rel="stylesheet" ...

  6. 推荐一款炫酷的提示框插件SweetAlert

    官方网址 http://t4t5.github.io/sweetalert/ 项目地址 https://github.com/t4t5/sweetalert

  7. 基于jquery的响应式提示框SweetAlert

    介绍款交互性非常不错的jquery弹出层插件,支持消息提示.错误提示.确认框提示等.交互式体验感非常不错,比如咱们现在体验非常不错的微信支付.支付宝等完成后的效果.不过本插件至少支持IE9+.使用方式 ...

  8. Android studio SweetAlert for Android

    找到个开源项目.github:https://github.com/pedant/sweet-alert-dialog 效果图:https://raw.githubusercontent.com/pe ...

  9. 提示框插件SweetAlert

    SweetAlert可以替代Javascript原生的alert和confirm等函数呈现的弹出提示框, 它将提示框进行了美化,并且允许自定义, 支持设置提示框标题.提示类型.内容展示图片.确认取消按 ...

  10. Ionic2中集成第三方控件Sweetalert

    Ionic2混合开发,入坑系列:Ionic2中集成第三方控件Sweetalert 注:Sweetalert2已经可以直接从npm中下载安装 npm install --save sweetalert2 ...

随机推荐

  1. Go之viper配置

    这个模块功能强大,读取配置,命令行,监听配置改变. 堪称多面手,在k8s,docker中,都多有应用. 这套应用,主要包括cobra,pflag,viper三件套. 了解得差不多啦...:) pack ...

  2. jQuery 核心 - noConflict() 方法[避免冲突的方法]

    定义和用法 noConflict() 方法让渡变量 $ 的 jQuery 控制权. 语法 jQuery.noConflict([removeAll]) 参数描述removeAll布尔值.指示是否允许彻 ...

  3. MyEclipse和tomcat结合编写jsp对于中文乱码的解决方法

    一.Java和jsp 中文乱码原因和解决方法: Java的内核和class文件是基于unicode的,这使Java程序具有良好的跨平台性,但也带来了一些中文乱码问题的麻烦.原因有两方面: 第一方面:J ...

  4. [转] babel入门基础

    背景 babel的官网说babel是下一代的js语法编译器,现在自己也在很多项目中使用了babel,可是自己对babel的认识呢,只停留在从google和别人项目中copy的配置代码上,内心感到很不安 ...

  5. 用jQuery实现Ajax

    前置知识:ajax原理,json字符串进行信息传递. Ajax主要的功能是实现了浏览器端 异步 访问服务器:通过浏览器的XMLHttpRequest对象发出小部分数据,与服务端进行交互, 服务端返回小 ...

  6. Codeforces 965E Short Code 启发式合并 (看题解)

    Short Code 我的想法是建出字典树, 然后让后面节点最多的点优先向上移到不能移为止, 然后gg. 正确做法是对于当前的节点如果没有被占, 那么从它的子树中选出一个深度最大的点换到当前位置. 用 ...

  7. Noj - 在线强化训练1

      1445 A 求n个整数的和   1564 B 判断一个数是否是完全数   1011 C 判素数(Prime number)   1566 D 输入一组整数,找出最小值   1200 E 判断三角 ...

  8. POJ 1979 红与黑

    题目地址: http://poj.org/problem?id=1979  或者  https://vjudge.net/problem/OpenJ_Bailian-2816 Red and Blac ...

  9. miniui中可以设置是否让页面进行分页 <div id="datagrid1" class="mini-datagrid" style="width:100%" allowAlternating="true" showpager="true"/> 就是设置showpager属性为true

    <div id="datagrid1" class="mini-datagrid" style="width:100%" allowA ...

  10. Centos7 安装PhantomJS

    1.下载地址:http://phantomjs.org/download.html 2.文件名:phantomjs-2.1.1-linux-x86_64.tar.bz2   # 下载好后进行解压(由于 ...