JQuery实现页面Loading效果
2015-12-09 10:28
726 查看
第一步:添加遮罩层和LOADING层
<div class="overlay"></div>
<div id="AjaxLoading" class="showbox">
<div class="loadingWord"><img src="../JS/waiting.gif">加载中,请稍候...</div>
</div>
第二步:添加CSS样式
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
.demo{margin:100px auto 0 auto;width:400px;text-align:center;font-size:18px;}
.demo .action{color:#3366cc;text-decoration:none;font-family:"微软雅黑","宋体";}
.overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:998;width:100%;height:100%;_padding:0 20px 0 0;background:#f6f4f5;display:none;}
.showbox{position:fixed;top:0;left:50%;z-index:9999;opacity:0;filter:alpha(opacity=0);margin-left:-80px;}
*html,*html body{background-image:url(about:blank);background-attachment:fixed;}
*html .showbox,*html .overlay{position:absolute;top:expression(eval(document.documentElement.scrollTop));}
#AjaxLoading{border:1px solid #8CBEDA;color:#37a;font-size:12px;font-weight:bold;}
#AjaxLoading div.loadingWord{width:180px;height:50px;line-height:50px;border:2px solid #D6E7F2;background:#fff;}
#AjaxLoading img{margin:10px 15px;float:left;display:inline;}
</style>
第三步:添加JS控制代码
<script>
$(document).ready(function () {
var h = $(document).height();
$(".overlay").css({ "height": h });
$("#btn3").click(function () {
ShowLoading();
$.post("../ASHX/Course.ashx", { json: s, cid: "1234567" }, function (data, textStatus) {
alert(data + " status:" + textStatus);
HiddenLoading();
})
})
function ShowLoading() {
$(".overlay").css({ 'display': 'block', 'opacity': '0.8' });
$(".showbox").stop(true).animate({ 'margin-top': '300px', 'opacity': '1' }, 200);
}
function HiddenLoading() {
$(".showbox").stop(true).animate({ 'margin-top': '250px', 'opacity': '0' }, 400);
$(".overlay").css({ 'display': 'none', 'opacity': '0' });
}
});
</script>
<div class="overlay"></div>
<div id="AjaxLoading" class="showbox">
<div class="loadingWord"><img src="../JS/waiting.gif">加载中,请稍候...</div>
</div>
第二步:添加CSS样式
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
.demo{margin:100px auto 0 auto;width:400px;text-align:center;font-size:18px;}
.demo .action{color:#3366cc;text-decoration:none;font-family:"微软雅黑","宋体";}
.overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:998;width:100%;height:100%;_padding:0 20px 0 0;background:#f6f4f5;display:none;}
.showbox{position:fixed;top:0;left:50%;z-index:9999;opacity:0;filter:alpha(opacity=0);margin-left:-80px;}
*html,*html body{background-image:url(about:blank);background-attachment:fixed;}
*html .showbox,*html .overlay{position:absolute;top:expression(eval(document.documentElement.scrollTop));}
#AjaxLoading{border:1px solid #8CBEDA;color:#37a;font-size:12px;font-weight:bold;}
#AjaxLoading div.loadingWord{width:180px;height:50px;line-height:50px;border:2px solid #D6E7F2;background:#fff;}
#AjaxLoading img{margin:10px 15px;float:left;display:inline;}
</style>
第三步:添加JS控制代码
<script>
$(document).ready(function () {
var h = $(document).height();
$(".overlay").css({ "height": h });
$("#btn3").click(function () {
ShowLoading();
$.post("../ASHX/Course.ashx", { json: s, cid: "1234567" }, function (data, textStatus) {
alert(data + " status:" + textStatus);
HiddenLoading();
})
})
function ShowLoading() {
$(".overlay").css({ 'display': 'block', 'opacity': '0.8' });
$(".showbox").stop(true).animate({ 'margin-top': '300px', 'opacity': '1' }, 200);
}
function HiddenLoading() {
$(".showbox").stop(true).animate({ 'margin-top': '250px', 'opacity': '0' }, 400);
$(".overlay").css({ 'display': 'none', 'opacity': '0' });
}
});
</script>
相关文章推荐
- jQuery Validate
- 给jquery easy-ui 添加右键菜单
- Struts2和Jquery整合使用异步请求
- jQuery easyui treegrid无法传参到后台bugger一记
- jquery插件ajaxupload实现文件上传操作
- jQuery源码,匿名函数自执行
- jQuery 遍历函数(w3school)
- jQuery实现页面顶部显示的进度条效果完整实例
- jQuery实现form表单元素序列化为json对象的方法
- jQuery中serializeArray()与serialize()的区别实例分析
- jQuery实现批量判断表单中文本框非空的方法(2种方法)
- jquery特效 点击展示与隐藏全文
- jQuery实现选项卡切换效果简单演示
- jquery根据label文本查找label元素
- jquery动态加载 去除js
- 锋利的JQuery —— 选择器
- jquery data()
- jquery.tmpl.js
- jquery.tmpl.min.js
- jquery学习(三)-ajax