jquery仿alert提示框、confirm确认对话框、prompt带输入的提示框插件[附实例演示]
jquery仿alert提示框、confirm确认对话框、prompt带输入的提示框插件实例演示
第一步:引入所需要的jquery插件文件:
http://www.angelweb.cn/Inc/eg/jquery.alerts.js
第二步:引入所需的样式:
#popup_container {font-family: Arial, sans-serif;font-size: 12px;min-width: 300px;max-width: 600px;background:#FFF;border:solid 5px #999;color:#000;-moz-border-radius:5px;-webkit-border-radius: 5px;border-radius: 5px;}
#popup_title {font-size:14px;font-weight:bold;text-align:center;line-height:1.75em;color:#666;background: #CCC url(/images/eg/title.gif) top repeat-x;border: solid 1px #FFF;border-bottom: solid 1px #999;cursor: default;padding:0em;margin:0em auto;}
#popup_content {background:16px 16px no-repeat url(/images/eg/info.gif);padding: 1em 1.75em;margin: 0em;}
#popup_content.alert {background-image: url(/images/eg/info.gif);}
#popup_content.confirm {background-image: url(/images/eg/important.gif);}
#popup_content.prompt {background-image: url(/images/eg/help.gif);}
#popup_message {padding-left: 48px;}
#popup_panel {text-align: center;margin:1em 0em 0em 1em;}
#popup_prompt {margin:.5em 0em;}
注意把上面样式中的图片先保存到本地,然后替换成自己的路径!
第三步:就可以直接引用了,看下面简单的实例:
$("#alert_button").click( function() {
jAlert('这是一个可自定义样式的警告对话框', '警告对话框');
});
$("#confirm_button").click( function(){
jConfirm('你确定这么做吗?', '确认对话框',function(r){
jAlert('是否确定 ' + r, '确定内容');
});
});
$("#prompt_button").click( function(){
jPrompt('输入字符:', '这里是默认值', '带输入框的提示框', function(r) {
if( r ){alert('你输入的是 ' + r)};
});
});
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>zhezhaoceng.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript" src="<%=contextPath %>/core/js/jquery/jquery-1.4.2.js"></script>
<script type="text/javascript" src="jquery.alerts.js"></script>
<style>
#popup_container {font-family: Arial, sans-serif;font-size: 12px;min-width: 300px;max-width: 600px;background:#FFF;border:solid 5px #999;color:#000;-moz-border-radius:5px;-webkit-border-radius: 5px;border-radius: 5px;}
#popup_title {font-size:14px;font-weight:bold;text-align:center;line-height:1.75em;color:#666;background: #CCC url(/images/eg/title.gif) top repeat-x;border: solid 1px #FFF;border-bottom: solid 1px #999;cursor: default;padding:0em;margin:0em auto;}
#popup_content {background:16px 16px no-repeat url(/images/eg/info.gif);padding: 1em 1.75em;margin: 0em;}
#popup_content.alert {background-image: url(/images/eg/info.gif);}
#popup_content.confirm {background-image: url(/images/eg/important.gif);}
#popup_content.prompt {background-image: url(/images/eg/help.gif);}
#popup_message {padding-left: 48px;}
#popup_panel {text-align: center;margin:1em 0em 0em 1em;}
#popup_prompt {margin:.5em 0em;}
</style>
<script type="text/javascript">
$("#alert_button").click( function() {
jAlert('这是一个可自定义样式的警告对话框', '警告对话框');
}); $("#confirm_button").click( function(){
jConfirm('你确定这么做吗?', '确认对话框',function(r){
jAlert('是否确定 ' + r, '确定内容');
});
}); $("#prompt_button").click( function(){
jPrompt('输入字符:', '这里是默认值', '带输入框的提示框', function(r) {
if( r ){alert('你输入的是 ' + r)};
});
}); </script>
</head> <body>
<div id="Con" class="ConDiv"> <fieldset>
<legend>警告提示框(Alert)</legend>
<pre> $("#alert_button").click( function() {
jAlert('这是一个可自定义样式的警告对话框', '警告对话框');
});
</pre>
<p>
<input id="alert_button" type="button" value="警告提示框">
</p>
</fieldset>
<script language="javascript">
$(function(){
$("#alert_button").click( function() {
jAlert('这是一个可自定义样式的警告对话框', '警告对话框');
});
});
</script> <fieldset>
<legend>确认对话框(Confirm)</legend>
<pre> $("#confirm_button").click( function(){
jConfirm('你确定这么做吗?', '确认对话框',function(r){
jAlert('是否确定 ' + r, '确定内容');
});
});
</pre>
<p>
<input id="confirm_button" type="button" value="确认对话框">
</p>
</fieldset>
<script language="javascript">
$(function(){
$("#confirm_button").click( function(){
jConfirm('你确定这么做吗?', '确认对话框',function(r){
jAlert('是否确定 ' + r, '确定内容');
});
});
});
</script> <fieldset>
<legend>带输入的提示框(Prompt)</legend>
<pre> jPrompt('输入字符:', '这里是默认值', '带输入框的提示框', function(r) {
if( r ) alert('你输入的是 ' + r);
});
</pre>
<p>
<input id="prompt_button" type="button" value="带输入框的提示框">
</p>
</fieldset>
<script language="javascript">
$(function(){
$("#prompt_button").click( function(){
jPrompt('输入字符:', '这里是默认值', '带输入框的提示框', function(r) {
if( r ){alert('你输入的是 ' + r)};
});
});
});
</script> <fieldset>
<legend>带HTML输出效果的对话框</legend>
<pre> jAlert('你可以使用HTML标签,比如 <strong>加粗</strong>, <em>斜体</em>,和 <u>下划线</u>!');
</pre>
<p>
<input id="alert_button_with_html" type="button" value="显示带有HTML标签效果的弹出框">
</p>
</fieldset>
<script language="javascript">
$(function(){
$("#alert_button_with_html").click( function(){
jAlert('你可以使用HTML标签,比如 <strong>加粗</strong>, <em>斜体</em>,和 <u>下划线</u>!');
});
});
</script>
</div>
</body>
</html>
jquery仿alert提示框、confirm确认对话框、prompt带输入的提示框插件[附实例演示]的更多相关文章
- 关于abp中使用的sweetalert对话框组件的confirm确认对话框中的一个坑
今天修改了一个功能,限制删除用户,在删除的时候不满足条件的时候提示用户原因,使用的sweet alert组件. abp框架前端集成了sweet alert 对http请求的error做了全局处理,我在 ...
- confirm确认对话框
还记得之前的javascript入门里的讲的confirm 消息对话框吗?不记得也没关系,我们先来回顾一下,然后在详细讲它. 复习: confirm 消息对话框通常用于允许用户做选择的动作,如:“你对 ...
- Unity3d UGUI 通用Confirm确认对话框实现(Inventory Pro学习总结)
背景 曾几何时,在Winform中,使用MessageBox对话框是如此happy,后来还有人封装了可以选择各种图标和带隐藏详情的MessageBox,现在Unity3d UGui就没有了这样的好事情 ...
- asp.net在后台弹出confirm确认对话框并获取用户选择的值做出相应的操作
在asp项目中,这种情况是经常出现的,前段时间通过查找资料以及自己尝试,找到一种解决方案,但是不知是否有更好的方案,以后发现再进行记录. 一.思路 在本次项目中,在一个函数中需要让用户判断,并根据用户 ...
- BootstrapDialog.confirm确认对话框
1. 依赖文件: bootstrap.js bootstrap-dialog.js bootstrap.css bootstrap-dialog.css 2.代码 BootstrapDialog.co ...
- 15 JavaScript弹窗(警告框alert、确认框confirm、提示框Promt)
警告框:window.alert().通常用于确认用户可以得到某些信息 <body> <script type="text/javascript" charset ...
- Selenium系列(九) - 针对alert窗口的处理(警告框、确认框、对话框)
如果你还想从头学起Selenium,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1680176.html 其次,如果你不懂前端基础知识, ...
- jquery easy ui 1.3.4 窗口,对话框,提示框(5)
5.1.window(窗口) 窗口我们在程序中会大量的使用,比如我们的添加.编辑都可以使用窗口实现,与winform的程序非常的类似.下面的代码是创建一个基本的窗口 $(function () { $ ...
- jquery mobile 实现自定义confirm确认框效果
类似删除的效果,在执行之前,一般需要添加确认对话框,点确认的话执行,取消按钮就不执行,传统的js if(confirm('确定删除吗?')) { //执行代码 } 这种效果比较丑,使用jquery m ...
随机推荐
- YII缓存Cache
缓存Cache 定义:将数据暂时存放在一个存储速度更快的介质上,下次读取数据时就可以从这个介质上来读取数据 介质:内存.文件.数据库(优化好的数据库) Yii缓存的分类:(framework/cach ...
- spring MVC fromeWork 與webwork2 mvc 比較
http://www.blogjava.net/xxxzheng/articles/7614.html 在当今的MVC framework里,似乎Webwork2逐渐成为主流, Webwork2+Sp ...
- 关于dialog的一点知识
一般我们比较常用的就是AlertDialog,这个一般也不直接构造,而是用系统提供的builder构造器去构造一个dialog. AlertDialog.Builder builder = new A ...
- 本机Font字体
void getFontList() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Str ...
- MVC小系列(十七)【自定义验证规则给下拉框】
因为下拉框不支持验证,所以写一个attribute特性,让它继承ValidationAttributemvc的特性验证,很直接,无论是数据安全特性上还是页面表现上都不错,它的运行机制: 前台表单验证规 ...
- js单击显示元素,点击元素本身以外隐藏元素
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 关于添加非系统framework后,import导入头文件时没有提示的解决办法
##1.选择target(就是左边你的工程target)—— BuildSettings —— search Paths 下的 User Header Search Paths(如图所示: ##2.双 ...
- thinkphp 缓存写入失败,网站报错
周末,正在家里休息,同事突然call 我,说网站打不开了,网站一直很正常的,突然成这样,肯定某个地方出问题了, 原来是网站所在的硬盘分区,没空间了,被mysql的日志占满了!!! 哎,好好的周末,在公 ...
- php 简单的验证码
注意事项: 验证的隐藏域的位置一定要在调用JS前.. 如: <input type="text" name="yzm" value="" ...
- CentOS 6.4 使用YUM 安装MySQL5.5
1.首先需要下载Yum的支持包: http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm 2.下载完成后将Yum库导入到你的 ...