JS通用弹窗,确定,取消可以回调方法。
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
/* 首页弹出层 */
.confirm-tips{width:100%; height:100%; background:url(apher.png); position:fixed; top:0; z-index:999999999;overflow: auto;}
.confirm-tips-box{width:500px; height:334px; background:#FFF; position:absolute;top:25%;}
.confirm-tips-box h2{display:block; margin-top:50px; text-align:center; font-size:36px; font-weight:normal; color:#3881eb;}
.confirm-tips-box p{font-size:20px; color:#757c8a; text-align:center; display:block; margin-top:36px;}
.autobut a.submissionqx{display:inline-block; width:188px; height:60px; -moz-border-radius:6px; -webkit-border-radius:6px; border-radius:6px; border:1px solid #3881eb; text-align:center; line-height:60px; color:#3881eb; margin:0 auto; margin-top:60px; margin-bottom:50px; margin-left:45px; margin-right:30px;}
.autobut a.submission{display:inline-block; width:188px; height:60px; -moz-border-radius:6px; -webkit-border-radius:6px; border-radius:6px; background:#3881eb; text-align:center; line-height:60px; color:#FFF; margin:0 auto; margin-top:60px; margin-bottom:50px;}
</style>
</head>
<body>
<input id='alter_btn' type='button' value='弹窗确定取消按钮'/>
<span id='msg'></span>
<script>
/**
* 共用弹窗 确定 取消按钮
* eg: option = {
* title:'标题',
* msg:'内容',
* confirm:function(){
* 点击确定执行的方法
* },
* cancel:function(){
* 点击取消执行的方法
* }
* }
* eg: $.confirm_tips(option);
* @param obj
*/
$.confirm_tips = function(obj){
if(obj && obj.msg != ''){
if(!obj.title){
obj.title = '系统提示';
}
var left = parseFloat(($(document).width()-500)/2);
var tips_html = '<div class="confirm-tips confirm-tips-common" >' +
'<div class="confirm-tips-box" style="left:'+left+'px;">\n' +
' <h2>'+obj.title+'</h2>\n' +
' <p style="padding: 0 15px">'+obj.msg+'</p>\n' +
' <div class="autobut">\n' +
' <a href="javascript:;" class="submissionqx confirm-tips-cancelbtn">取消</a>\n' +
' <a href="javascript:;" class="submission confirm-tips-confirmbtn">确定</a>\n' +
' </div>\n' +
' </div></div>';
if($('.confirm-tips-common').length <= 0){
$('body').append(tips_html);
}
$('.confirm-tips-confirmbtn').click(function(){
if(obj.confirm){
obj.confirm();
}
$('.confirm-tips-common').remove();
$('.confirm-tips-confirmbtn').unbind();
})
$('.confirm-tips-cancelbtn').click(function(){
if(obj.cancel){
obj.cancel();
}
$('.confirm-tips-common').remove();
$('.confirm-tips-cancelbtn').unbind();
})
}
} $('#alter_btn').click(function(){
var option = {
title:'标题',
msg:'内容',
confirm:function(){
$('#msg').text('确定');
},
cancel:function(){
$('#msg').text('取消');
}
};
$.confirm_tips(option);
})
</script>
</body>
</html>
JS通用弹窗,确定,取消可以回调方法。的更多相关文章
- 关于ElementUI中MessageBox弹框的取消键盘触发事件(enter,esc)关闭弹窗(执行事件)的解决方法
好久没见了 在项目中遇到一个小小的需求,总结了一下! 详细我就不介绍了,相信大家用过的话,很了解.详见文档-----------> http://element-cn.eleme.io/#/zh ...
- JS~jwPlayer为js预留的回调方法大总结
对于一个成功的产品,它是对外封闭的,但又是对外开放的,这句话并不矛盾,让我来说一下,说它对外封闭是因为它本身的代码不允许你去修改,而说它开放,是因为它为我们定义了很多API,或者叫回调方法,对于jwp ...
- 常用js,css文件统一加载方法,并在加载之后调用回调函数
原创内容,转载请注明出处! 为了方便资源管理和提升工作效率,常用的js和css文件的加载应该放在一个统一文件里面完成,也方便后续的资源维护.所以我用js写了以下方法,存放在“sourceControl ...
- 【转】第5篇:Xilium CefGlue 关于 CLR Object 与 JS 交互类库封装报告:自动注册JS脚本+委托回调方法分析
作者: 牛A与牛C之间 时间: 2013-11-19 分类: 技术文章 | 暂无评论 | 编辑文章 主页 » 技术文章 » 第5篇:Xilium CefGlue 关于 CLR Object 与 JS ...
- 【转】第4篇:Xilium CefGlue 关于 CLR Object 与 JS 交互类库封装报告:委托回调方法分析
作者: 牛A与牛C之间 时间: 2013-11-18 分类: 技术文章 | 暂无评论 | 编辑文章 主页 » 技术文章 » 第4篇:Xilium CefGlue 关于 CLR Object 与 JS ...
- 关于js回调方法 js递归时使用方法
js中递归调用本身可以这样: function a1(n){ a1(n)}但是如果需要在参数n进行自增的情况下判断会出错: function a1(n){ if(n>10) return 'aa ...
- jwPlayer为js预留的回调方法
参考地址:http://www.cnblogs.com/lori/archive/2014/05/05/3709459.html 应用场合 播放时记录当前视频的时间,播放完成时写入完成的时间,像这些功 ...
- js静态方法与实例方法定义,js回调方法定义
主要为了回调方法,随便把静态言法和实例方法也回顾一下. <script type="text/javascript"> var fun = { //下面是静态方法(第一 ...
- vue.js 同级组件之间的值传递方法(uni-app通用)
vue.js 兄弟组件之间的值传递方法 https://blog.csdn.net/jingtian678/article/details/81634149
随机推荐
- React - React Developer Tools开发者工具的安装与使用(Chrome调试插件)
原文地址:http://www.cnplugins.com/zhuanti/how-to-use-react-tools.html 虽然我们曾经在React开发者工具的基础介绍里面有概括性的介绍过Re ...
- Python初学者第十一天 文件处理_batch
11day 文件的操作分为读.写.修改 1.读: f = open(file='D:\新建文本文档.txt',mode='r',encoding='gbk') data = f.read() prin ...
- CentOS 6 网络yum源配置
# CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update ...
- SAP Fiori + Vue = ?
2017年3月28日,我到国内一个SAP CRM客户那里,同他们的架构师关于二次开发的UI框架选择SAP UI5还是Vue进行了一番探讨.回到SAP研究院之后,我把这个问题扔到了公司的微信群里,引起了 ...
- perl学习---控制:unless,until,next,redo,last
1.1.unless unless 的含义是:除非条件为真,否则执行块中的代码,和if正好相反 unless($fred=~ /^[A-Z_]\w*$/i){ print “The value of ...
- Git bash 终止git log 命令
Git bash中 可以通过键入: q ,结束该命令.
- 【BZOJ3757】苹果树(树上莫队)
点此看题面 大致题意: 每次问你树上两点之间路径中有多少种颜色,每次询问可能会将一种颜色\(a\)看成\(b\). 树上莫队 这题是一道树上莫队板子题. 毕竟求区间中有多少种不同的数是莫队算法的经典应 ...
- PHP中的 array_filter 函数
<?php function test_odd($var) { return($var & 1); } $a1=array("a","b",2,3 ...
- Entity Framework——读写分离
1 实现 CustomDbContext扩展了DbContext,其构造函数带有形式参nameOrConnectionString,可以在使用CustomDbContext时指定数据库连接字符串. D ...
- Kernel Ridge Regression
回顾一下岭回归,岭回归的目的是学习得到特征和因变量之间的映射关系,由于特征可能很高维,所以需要正则化 岭回归的目标函数是 $$ \sum_{i=1}^n \left\|y-X\beta\right\| ...