今天逛github的时候发现一个非常萌的alert,比IE和各大浏览器的原alert美多惹。

github项目地址:https://github.com/t4t5/sweetalert

通过git clone到本地

项目本身也有一个非常Nice的说明文档,跟着操作就能看懂各种做好的萌萌哒的alert了。

参考:https://www.ludu.co/lesson/how-to-use-sweetalert

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>index1</title>
<script type="text/javascript" src="sweetalert.min.js"></script>
<link rel="stylesheet" href="sweetalert.css">
</head>
<body>
<script>
//sweetAlert("Hello world!")
sweetAlert({
title: "Oops!",
text: "Something went wrong on the page!",
type: "error"
}); </script>
</body>
</html>

配合jQuery还可以设置其他的alert哦

<button class="delete-photo" data-photo-id="">Delete photo</button>

   <script>
$('button.delete-photo').click(function() {
var photoId = $(this).attr("data-photo-id");
deletePhoto(photoId);
}); function deletePhoto(photoId) {
swal({
title: "Are you sure?",
text: "Are you sure that you want to delete this photo?",
type: "warning",
showCancelButton: true,
closeOnConfirm: false,
confirmButtonText: "Yes, delete it!",
confirmButtonColor: "#ec6c62"
}, function() {
$.ajax({
url: "/api/photos/" + photoId,
type: "DELETE"
})
.done(function(data) {
swal("Deleted!", "Your file was successfully deleted!", "success");
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
});
}
</script>

最新文章

  1. ABP框架 - 时间
  2. HDU 4081Qin Shi Huang&#39;s National Road System(次小生成树)
  3. thinkphp自动验证---$_validate
  4. ios https适配(单向验证)
  5. C++ virtual虚函数
  6. C#常用命名空间
  7. Response.Redirect引起的“无法在发送HTTP标头之后进行重定向”
  8. DevOps的修炼之路!
  9. Android 之 自动匹配字符AutoCompleteTextView
  10. 【bzoj1051】 [HAOI2006]受欢迎的牛 tarjan缩点判出度算点数
  11. mvcAPI (入门 3)(源码)
  12. (VS) TFS lost mapping suddenly.
  13. MongoDB 相关下载
  14. linux下oracle11g R2的启动与关闭监听、数据库
  15. 使用android x86进行android应用开发.
  16. dhtmlx之dhtmlXGrid显示数据
  17. vs打开项目,创建虚拟目录,提示权限不足无法写入配置文件
  18. iOS的消息转发机制详解
  19. linux磁盘大小获取和文件大小获取
  20. 中间人攻击(MITM)之数据截获原理

热门文章

  1. .net 类型转换
  2. USB的前世今生
  3. 启动Tomcat提示:指定的服务未安装
  4. Android5.1 - 通讯录建立群组
  5. 分页功能的实现——Jdbc &amp;&amp; JSP
  6. IoC是什么
  7. Redux源码分析之combineReducers
  8. 42. leetcode 70. Climbing Stairs
  9. 40. leetcode 202. Happy Number
  10. 超强、超详细Redis数据库入门教程(转载)