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