轻量级警报和确认弹出插件 jQuery堆栈警报

  • 源码大小:9.53KB
  • 所需积分:1积分
  • 源码编号:19JP-3207
  • 浏览次数:530次
  • 最后更新:2023年05月18日
  • 所属栏目:其他
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

Stack Alert是一个轻量级但可自定义的jQuery警报插件,用于为那些需要在web应用程序上显示错误消息或请求确认的人创建警报弹出窗口和确认对话框。

如何使用它:

1.导入jQuery Stack Alert插件的JavaScript和样式表。

  1. <link rel="stylesheet" href="/path/to/style.css" />
  2. <script src="/path/to/cdn/jquery.min.js"></script>
  3. <script src="/path/to/cdn/script.js"></script>

2.创建一个基本的警报弹出窗口。

  1. stal({
  2. title: 'Alert Message',
  3. text: 'This is an alert message',
  4. showOkButton: true,
  5. })

3.使用Promise创建一个确认对话框然后()作用

  1. stal({
  2. title: 'Confirm Dialog',
  3. text: 'Are you sure to delete?',
  4. showConfirmButton: true,
  5. showCancelButton: true,
  6. }).then(function(result) {
  7. if (result) {
  8. // confirmed
  9. } else {
  10. // rejected
  11. }
  12. });

4.可用的警报类型:

  • 错误
  • 警告
  • 信息
  • 成功
  1. stal({
  2. title: 'Confirm Dialog',
  3. text: 'Are you sure to delete?',
  4. showConfirmButton: true,
  5. showCancelButton: true,
  6. type: 'error',
  7. }).then(function(result) {
  8. if (result) {
  9. // confirmed
  10. } else {
  11. // rejected
  12. }
  13. });

预览截图