alertify.js是一款JS插件,主要实现提示功能,用于代替js中的alert,confirm,prompt,显示友好的提示框。
![]() |
---|
<link href="static/css/alertify.min.css" rel="stylesheet" type="text/css">
<script src="static/js/alertify.min.js"></script>
var
$ = function (id) {
return document.getElementById(id);
},
//初始化操作
reset = function () {
alertify.set({
labels : {
ok : "确认",
cancel : "取消"
},
delay : 5000,
buttonReverse : false,
buttonFocus : "ok"
});
};
//绑定
$("alert").onclick = function () {
reset();
alertify.alert("提示框");
return false;
};
//绑定
$("confirm").onclick = function () {
reset();
alertify.confirm("确认框", function (e) {
if (e) {
alertify.success("点击确认");
} else {
alertify.error("点击取消");
}
});
return false;
};
//绑定
$("prompt").onclick = function () {
reset();
alertify.prompt("提示输入框", function (e, str) {
if (e) {
alertify.success("点击确认,输入内容为: " + str);
} else {
alertify.error("点击取消");
}
}, "默认值");
return false;
};
官网地址 :https://alertifyjs.com/
GitHub 地址 :https://github.com/fabien-d/alertify.js