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/ 插件库, 但是插件市场上有太多类 ...
随机推荐
- Visual Ribbon Editor for CRM 连接
- 用ng-style修改元素的color, size等
1) 在Controller中定义变量myStyle var myStyle={'background-color':'blue'} $scope.myStyle = myStyle; 2) 在HTM ...
- jquery遍历指定元素下的img图片改变其路径
$(".jieshao img").each(function (i) { $(this).attr("src", "manager/" + ...
- 安装配置Glusterfs
软件下载地址:http://bits.gluster.org/pub/gluster/glusterfs/3.4.2/x86_64/ 192.168.1.11 10.1.1.241 glusterfs ...
- redis管道技术
1.redis管道pipeline解决的问题: 由于redis通信是通过tcp协议基础,并且是堵塞的处理方式,在第一个请求没有执行并返回前,无法处理第二个请求.所以事件浪费在了网络传输和堵塞请求中. ...
- SpringBoot在Kotlin中的实现(二)
根据现在的开发模式和网上的一些资料,SpringBoot需要对业务和操作进行分层,通常分为controller.entity.service.respository等结构.下面以Kotlin官网的例子 ...
- linux tomcat启动后无法访问
先是按网上资料先下载安装包,然后上传到linux,启动后发现8080端口并未被占用.查了很多资料,不知道神马原因了.最后用yum安装后就可以访问了. 教程如下: 本教程介绍在CentOS 7服务器上使 ...
- VMware扩展Linux根目录磁盘空间(Centos版本)
1.Centos 关机,选择编辑虚拟机设置,硬盘,在实用工具那里选择“扩展”,指定你需要的存储大小 2.启动客户机操作系统Centos,查看磁盘情况 输入指令 fdisk -l 显示结果如下 Disk ...
- java的list遍历
for(String str : list) {//增强for循环,其内部实质上还是调用了迭代器遍历方式,这种循环方式还有其他限制,不建议使用. System.out.println(str); } ...
- Linux中设置vi编辑器的编码格式以及使用
vi ~/.vimrc set fileencodings=utf-8,gbk set termencoding=utf-8 set encoding=utf-8 vim的多行移动 一.连续的十几行到 ...