JQUERY 简单易用的提示框插件
业务开发过程中,为了避免用户的误操作,提示框是必要的,于是琢磨出了下面这个使用,方便的提示框
还要引入遮罩层的样式如下:
/*弹出层*/
.input{height: 32px;border: 1px solid #ccc;border-radius:1px;width:240px;}
.layer_icon{ background:url(../images/b_layer.png) no-repeat; display:inline-block;}
.w460{width: 460px;}
/*弹出通用样式*/
.b_l{border-radius:4px; box-shadow:1px 2px 4px #6c6e72;-moz-box-shadow:1px 2px 4px #6c6e72;-webkit-box-shadow:1px 2px 4px #6c6e72;background:#fff;position:fixed;z-index:10}
使用方法: tm_dialog(options)
function tm_dialoag(options){
var defaults = {
title:"提示",
content:"请输入内容 !",
width:460,
height:220,
sureText:"确定",
cancleText:"取消",
showButton:true,
callback:function(){}
};
var opts = $.extend({},defaults,options);
//初始化拖拽
$("body").append("<div class='b_l w460 popanimate' id='dialogbox'>"+
" <div class='bcom_ti'>"+
" <a href='javascript:void(0);' class='bide layer_icon close fr'></a> <span>"+opts.title+"</span>"+
" </div>"+
" <div class='bcom_cent'>"+
" <p class='bcomti'>"+opts.content+"</p>"+
" <p class='bcoma'>"+
" <a href='javascript:void(0);' class='bc_abut1 sure'>"+opts.sureText+"</a>"+
" <a href='javascript:void(0);' class='bc_abut2 close'>"+opts.cancleText+"</a>"+
" </p>"+
" </div>"+
"</div>").append("<div class='tmui-overlay' style='height:"+$(window).height()+"px'></div>");
$("#dialogbox").tmDrag({"handle":".bcom_ti"});
var $dialog = $("#dialogbox");
if(!opts.showButton)$dialog.find(".bcoma").remove();
var contentHeight = opts.height-200;
$dialog.find(".bcomti").css({"height":contentHeight,"lineHeight":contentHeight+"px"});
$dialog.width(opts.width);
$dialog.height(opts.height);
tm_center_dialog($dialog);
//关闭按钮绑定点击事件
$dialog.find(".close").click(function(){
$dialog.next().remove();//删除遮罩层
$dialog.slideUp("slow",function(){
$(this).remove();
});
if(opts.callback)opts.callback(false);
});
$dialog.find(".sure").click(function(){
$dialog.next().remove();//删除遮罩层
$dialog.slideUp("slow",function(){
$(this).remove();
});
if(opts.callback)opts.callback(true);
});
//窗口resize
$(window).resize(function(){
tm_center_dialog($dialog);
});
};
//层居中
function tm_center_dialog($dialog){
var windowWidth = $(window).width();
var windowHeight = getClientHeight();
var dialogWidth = $dialog.width();
var dialogHeight = $dialog.height();
var left = (windowWidth-dialogWidth)/2;
var top = (windowHeight-dialogHeight)/2;
$dialog.css({left:left,top:top});
};
function getClientHeight() {
var clientHeight = 0;
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight
: document.documentElement.clientHeight;
} else {
clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight
: document.documentElement.clientHeight;
}
return clientHeight;
};
JQUERY 简单易用的提示框插件的更多相关文章
- jQuery简单易用的网页内容打印插件
简要教程 jQuery.print是一款简单易容且功能强大的网页内容打印jQuery插件.该网页打印插件可以打印指定区域的网页元素,可以指定跳过不打印某些元素,还可以打印整个页面内容.并且提供了丰富的 ...
- [原]发布一个jQuery提示框插件,Github开源附主站,jquery.tooltips.js
一个简单精致的jQuery带箭头提示框插件 插件写好快一年了,和一个 弹出框插件(点击查看) 一起写的,一直没有整理出来,昨天得功夫整理并放到了github上,源码和网站均可在线看或下载. CSS中的 ...
- jquery仿alert提示框、confirm确认对话框、prompt带输入的提示框插件[附实例演示]
jquery仿alert提示框.confirm确认对话框.prompt带输入的提示框插件实例演示 第一步:引入所需要的jquery插件文件: http://www.angelweb.cn/Inc/eg ...
- 基于jQuery消息提示框插件Tipso
今天要分享的这款jQuery消息提示框插件名叫Tipso,它的特点是可以定义提示框的显示位置,以及动态改变提示框的提示内容,应该说是一款相当灵活的jQuery消息提示框插件.效果图如下: 在线预览 ...
- 强大的响应式jQuery消息通知框和信息提示框插件
lobibox是一款功能很强大的jQuery消息通知框和信息提示框插件.这个插件分为两个部分:消息通知框和信息提示框.它能很好的结合Bootstrap使用. 信息提示框 lobibox的信息提示框能够 ...
- bootstrap 弹窗或者提示框插件 bootstrap-growl 和bootstrap-notify
Bootstrap简单好用的页面右上角咆哮提示框 - daidaineteasy的专栏 - CSDN博客https://blog.csdn.net/daidaineteasy/article/deta ...
- jQuery自定义漂亮的下拉框插件8种效果演示
原始的下拉框不好看这里推荐一个jQuery自定义漂亮的下拉框插件8种效果演示 在线预览 下载地址 实例代码 <!DOCTYPE html> <html lang="en&q ...
- Dropdown.js基于jQuery开发的轻量级下拉框插件
Dropdown.js 前言 在SPA(Single Page Application)盛行的时代,jQuery插件的轮子正在减少,由于我厂有需求而开发了这个插件.如果觉得本文对您有帮助,请给个赞,以 ...
- Flutter Toast消息提示框插件
Flutter Toast消息提示框插件 在开发flutter项目中,想必大家肯定会用到toast消息提示,说到这里, 大家肯定会想到https://pub.dev/ 插件库, 但是插件市场上有太多类 ...
随机推荐
- Cookie快速入门实践
第一个servlet[比如是CookieDemo01]中的代码如下: import javax.servlet.http.Cookie; //--------省略若干代码----------- pro ...
- ElasticSearch Java API
ElasticSearch-Java Client类型 ElasticSearch-TransportClient环境准备 ElasticSearch-TransportClient连接 Elasti ...
- css实战第三天小结
1.谈一谈对层级的理解: 如果对两个并列的子元素都设置了相对于同一个父元素(如果没有设置父元素那么默认相对于浏览器而言)进行了定位(相对定位),则这两个都具有相同的层级(默认为0),他们的trbl也默 ...
- 小众Python库介绍
Python 是世界上发展最快的编程语言之一.它一次又一次地证明了自己在开发人员和跨行业的数据科学中的实用性.Python 及其机器学习库的整个生态系统使全世界的用户(无论新手或老手)都愿意选择它.P ...
- web app 、native app、hybrid app比较
web app .native app.hybrid app比较 产品新人学习路 关注 2017.06.04 14:52* 字数 1887 阅读 11476评论 1喜欢 15 之前做讨论的时候,提出了 ...
- angularjs探秘<五> 举足轻重的scope
scope在angular中的作用可谓举足轻重,不理解scope就不会angular: scope是应用在 HTML (view) 和 JavaScript (controller)之间的纽带. sc ...
- 使用tpcc-mysql进行性能测试
tpcc-mysql的github地址:https://github.com/Percona-Lab/tpcc-mysql tpcc-mysql源代码进行编译,服务器上需要安装有mysql git c ...
- uva-10391-枚举
题意:对于输入的字符串,判断是否存在一个单词a=b+c 俩种方法,枚举每一个单词进行拼接,复杂度是n*n 枚举每一个单词,对单词进行substr,判断substr出来的是不在map里面 #includ ...
- python venv actieve uninstall pack-name sitepage
- [多线程]wait和notify
线程之间的通信 使用wait/notify方法实现线程间的通信.这两个方法都是Object类的方法,也就是说Java所有的对象都提供这两个方法.1.wait和notify必须配合synchroni ...