插件使用文档和下载地址:http://craftpip.github.io/jquery-confirm/

引入文件

因为我们是在 BootStrap + jQuery 上实现的,首先需要

1、先引入 jQuery 库,然后是Bootstrap 需要的两个核心文件(css 和 js)

2、然后在后面引入 两个核心文件

jquery-confirm.min.js 和 jquery-confirm.min.js

下载地址:点此 jquery-confirm

代码如下

  1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2. <!DOCTYPE html>
  3. <html lang="zh-CN">
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
  9. <meta name="description" content="">
  10. <meta name="author" content="">
  11. <link rel="icon" href="/plugins/bootstrap-3.3.7/favicon.ico">
  12. <title>BootStrap 和 jQuery 结合美化弹出框</title>
  13. <!-- Bootstrap core CSS -->
  14. <link href="/plugins/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
  15. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  16. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  17. <!--[if lt IE 9]>
  18. <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  19. <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
  20. <![endif]-->
  21. </head>
  22. <body>
  23. <!-- Bootstrap core JavaScript
  24. ================================================== -->
  25. <!-- Placed at the end of the document so the pages load faster -->
  26. <script src="/static/js/jquery.min.js"></script>
  27. <script src="/plugins/bootstrap-3.3.7/js/bootstrap.js"></script>
  28. <script src="/static/js/jquery-confirm.min.js"></script>
  29. <link rel="stylesheet" href="/static/css/jquery-confirm.min.css">
  30. <script>
  31. $.alert({
  32. title: 'Alert!',
  33. content: 'Simple alert!',
  34. });
  35. </script>
  36. </body>
  37. </html>

主要是 第16行 和 31-32行引入。

  1. $.alert({
  2. title: 'Alert!',
  3. content: 'Simple alert!',
  4. });

是调用语法。下面会介绍。

基本用法

引入上面的文件后,我们只需要在引入的后面进行使用了。

1、alert 确认框

  1. $.alert({
  2. title: 'Alert!',
  3. content: 'Simple alert!',
  4. });

效果图如下

2、confirm 询问框

  1. $.confirm({
  2. title: 'Confirm!',
  3. content: 'Simple confirm!',
  4. buttons: {
  5. confirm: function () {
  6. $.alert('Confirmed!');
  7. },
  8. cancel: function () {
  9. $.alert('Canceled!');
  10. },
  11. else: {
  12. text: 'else',
  13. btnClass: 'btn-blue',
  14. keys: ['enter', 'shift'],
  15. action: function(){
  16. $.alert('Something else?');
  17. }
  18. }
  19. }
  20. });

效果图如下

3、prompt 输入框

  1. $.confirm({
  2. title: 'Prompt!',
  3. content: '' +
  4. '<form action="" class="formName">' +
  5. '<div class="form-group">' +
  6. '<label>Enter something here</label>' +
  7. '<input type="text" placeholder="Your name" class="name form-control" required />' +
  8. '</div>' +
  9. '</form>',
  10. buttons: {
  11. formSubmit: {
  12. text: 'Submit',
  13. btnClass: 'btn-blue',
  14. action: function () {
  15. var name = this.$content.find('.name').val();
  16. if(!name){
  17. $.alert('provide a valid name');
  18. return false;
  19. }
  20. $.alert('Your name is ' + name);
  21. }
  22. },
  23. cancel: function () {
  24. //close
  25. },
  26. },
  27. onContentReady: function () {
  28. // bind to events
  29. var jc = this;
  30. this.$content.find('form').on('submit', function (e) {
  31. // if the user submits the form by pressing enter in the field.
  32. e.preventDefault();
  33. jc.$$formSubmit.trigger('click'); // reference the button and click it
  34. });
  35. }
  36. });

效果图如下

4、dialog 对话框

  1. $.dialog({
  2. title: 'Text content!',
  3. content: 'Simple modal!',
  4. });

效果图如下

5、确认是否跳转

HTML

  1. <a class="baidu" data-title="Goto baidu?" href="http://www.baidu.com">Goto baidu</a>

Javascript

  1. $('a.baidu').confirm({
  2. content: "是否跳转到百度",
  3. });
  4. $('a.baidu').confirm({
  5. buttons: {
  6. hey: function(){
  7. location.href = this.$target.attr('href');
  8. }
  9. }
  10. });

这里就介绍这几个常用的吧,更多的请 点此

效果图是 点击链接后,出来一个询问框,点击确认会跳转到 百度

简短的用法

  1. $.alert('Content here', 'Title here');
  2. $.confirm('A message', 'Title is optional');
  3. $.dialog('Just to let you know');

这里就介绍这么多了,更多内容,请直接访问 http://craftpip.github.io/jquery-confirm/

本文地址:https://liuyanzhao.com/6846.html

jQuery+bootstrap实现美化警告/确认/提示对话框插件相关推荐

  1. ios警告与提示对话框

    进行iOS开发过程中,不可避免的使用到各种提醒,来提醒用户当前操作,或是为了警告,或是为了数据缓冲. 本文介绍了使用 UIAlertController和UIAlertAction两个类,完成三种状态 ...

  2. 离开页面前显示确认提示对话框(兼容IE,firefox) = how to Catch Win...

    为什么80%的码农都做不了架构师?>>>    http://blog.163.com/lgh_2002/blog/static/44017526201061334953256/ & ...

  3. jQuery+Bootstrap美化弹出框

    项目中很多弹出的警告框是通过alert()弹出的浏览器警告框,样式比较丑陋且和页面使用的Bootstrap框架样式不吻合,因此需要修改弹出框样式. 采用jQuery+Bootstrap的方式这样弹出的 ...

  4. odoo开发笔记 -- 异常、错误、警告、提示、确认信息显示

    odoo开发笔记 -- 异常.错误.警告.提示.确认信息显示 参考文章: (1)odoo开发笔记 -- 异常.错误.警告.提示.确认信息显示 (2)https://www.cnblogs.com/he ...

  5. jquery,bootstrap实现的用户名片信息提示

    原文:jquery,bootstrap实现的用户名片信息提示 源代码下载地址:http://www.zuidaima.com/share/1737371579649024.htm 鼠标移动到头像上时提 ...

  6. Jquery提示框效果(确认提示框)

    <!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8" ...

  7. Jquery 弹出对话框插件xcConfirm.js

    Jquery 弹出对话框插件xcConfirm.js,感觉很方便使用,使用方法如下: <!DOCTYPE html> <html><head><meta ch ...

  8. innerHTMl和确认提示的使用

    现在学习对层的信息控制,即控制一个层中显示什么信息,在网上查找许多资料才知道使用innerHTML属性来控制层的值,这个innerHTML跟表单里面的value属性有点类似,能够控制层的显示值.比如说 ...

  9. 显示消息提示对话框(WebForm)

    1: /// <summary> 2: /// 显示消息提示对话框. 3: /// Copyright (C) Maticsoft 4: /// </summary> 5: p ...

  10. android确认密码代码,Android手机卫士之确认密码对话框

    本文接着实现"确认密码"功能,也即是用户以前设置过密码,现在只需要输入确认密码 布局文件和<Android 手机卫士--设置密码对话框>中的布局基本类似,所有copy一 ...

最新文章

  1. 远程办公如何保持高效?这群开发者们是这样做的
  2. Android 读取meta-data元素的数据
  3. Python之Fabric
  4. Day 1: Bower —— 管理你的客户端依赖关系
  5. UPS故障案例集(一)
  6. what you should do when you are alone
  7. 如何去除字符串中的 “\n“ ?80% 的同学错了!
  8. pclint 与vs2010结合识别预处理器定义
  9. Plugin 框架 开发实录
  10. appium使用教程python_appium使用教程(一 环境搭建)-------------2.安装部署
  11. 易语言卷帘菜单与json_易语言卷帘式菜单加背景图片源码
  12. VMware网络桥接设置
  13. 程序员的工资到底花到哪里去了?
  14. 人工智能会代替人工翻译?知行翻译:这是不可能地!
  15. y7000p装win10 工作站专业版,第三方驱动导致触摸板 失灵
  16. 1553B通信项目开发笔记(四)bu61580程序编写,实现回环之RT端
  17. linux服务器上tcp有大量time_wait状态的解决方法和原因解释
  18. 无线网怎么建立虚拟服务器,Win7创建虚拟WiFi热点共享的教程
  19. 什么是非功能性测试?
  20. 【报告分享】2021上半年热搜榜趋势报告-新浪微博(附下载)

热门文章

  1. xticks函数--Matplotlib
  2. 【TeeChart .NET教程】(六)使用系列
  3. 使用cxf3.0.4搭建webservice服务需要的最精简jar包
  4. “互联网+”时代,网络安全市场将达千亿级别
  5. Android开发指南(39) —— Testing Fundamentals
  6. [20150803]触发器对dml的影响.txt
  7. 戴尔vStart:加快虚拟化,并马上应用戴尔私有云
  8. CIE Radar 2006(ICR2006)开始征文了
  9. java的中文源代码
  10. error: Unexpected trailing comma (comma-dangle) at src\components\Login.vue:99:4: