jquery animate實(shí)現(xiàn)鼠標(biāo)放上去顯示離開(kāi)隱藏效果
更新時(shí)間:2013年07月21日 17:53:06 作者:
本文為大家介紹下使用jquery animate實(shí)現(xiàn)鼠標(biāo)放上去顯示,離開(kāi)就隱藏的效果,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助
1、CSS樣式:
@CHARSET "UTF-8";
* 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;
}
.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;
}
2、JS:
/**
* 加載動(dòng)畫(huà)窗口
*
* @author dendy
* @since 2013-7-19 10:13:05
*/
function getLoadingHtml(msg) {
if(!msg) msg = "加載";
var html = "<div id='loadingDiv'>"
+ "<div style='height: 1325px; display: none; opacity: 0;' class='overlay'></div>"
+ "<div style='opacity: 0; margin-top: 250px;' id='AjaxLoading' class='showbox'>"
+ "<div class='loadingWord'>"
+ "<img src='" + Util.getContentPath() +"/images/ajax-loader.gif'>" + msg + "中,請(qǐng)稍候..."
+ "</div>"
+ "</div>"
+ "<div style='height: 1200px;'></div>"
+ "</div>";
return html;
}
function ajaxLoadingInit(msg) {
var loadingDiv = getLoadingHtml(msg);
var h = $(document).height();
$(".overlay").css({"height": h});
var div = $("body").find("#loadingDiv");
div.remove();
$("body").append($(loadingDiv));
}
/**
* 開(kāi)始顯示loading,在ajax執(zhí)行之前調(diào)用
* @param msg 操作消息,"加載", "保存", "刪除"
*/
function startLoading(msg) {
ajaxLoadingInit(msg);
$(".overlay").css({'display':'block','opacity':'0.8'});
$(".showbox").stop(true).animate({'margin-top':'300px','opacity':'1'},200);
}
/**
* 加載完成后隱藏,在ajax執(zhí)行完成后(complete)調(diào)用
*/
function endLoading() {
$(".showbox").stop(true).animate({'margin-top':'250px','opacity':'0'},400);
$(".overlay").css({'display':'none','opacity':'0'});
}
3、調(diào)用例子:
startLoading();
$.ajax({
type : "POST",
url : this.url,
dataType : "json",
data : this.args,
success : function (data) {
},
complete : function () {
if (self.showLoading == true) endLoading();
},
error : this.error
});
復(fù)制代碼 代碼如下:
@CHARSET "UTF-8";
* 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;
}
.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;
}
2、JS:
復(fù)制代碼 代碼如下:
/**
* 加載動(dòng)畫(huà)窗口
*
* @author dendy
* @since 2013-7-19 10:13:05
*/
function getLoadingHtml(msg) {
if(!msg) msg = "加載";
var html = "<div id='loadingDiv'>"
+ "<div style='height: 1325px; display: none; opacity: 0;' class='overlay'></div>"
+ "<div style='opacity: 0; margin-top: 250px;' id='AjaxLoading' class='showbox'>"
+ "<div class='loadingWord'>"
+ "<img src='" + Util.getContentPath() +"/images/ajax-loader.gif'>" + msg + "中,請(qǐng)稍候..."
+ "</div>"
+ "</div>"
+ "<div style='height: 1200px;'></div>"
+ "</div>";
return html;
}
function ajaxLoadingInit(msg) {
var loadingDiv = getLoadingHtml(msg);
var h = $(document).height();
$(".overlay").css({"height": h});
var div = $("body").find("#loadingDiv");
div.remove();
$("body").append($(loadingDiv));
}
/**
* 開(kāi)始顯示loading,在ajax執(zhí)行之前調(diào)用
* @param msg 操作消息,"加載", "保存", "刪除"
*/
function startLoading(msg) {
ajaxLoadingInit(msg);
$(".overlay").css({'display':'block','opacity':'0.8'});
$(".showbox").stop(true).animate({'margin-top':'300px','opacity':'1'},200);
}
/**
* 加載完成后隱藏,在ajax執(zhí)行完成后(complete)調(diào)用
*/
function endLoading() {
$(".showbox").stop(true).animate({'margin-top':'250px','opacity':'0'},400);
$(".overlay").css({'display':'none','opacity':'0'});
}
3、調(diào)用例子:
復(fù)制代碼 代碼如下:
startLoading();
$.ajax({
type : "POST",
url : this.url,
dataType : "json",
data : this.args,
success : function (data) {
},
complete : function () {
if (self.showLoading == true) endLoading();
},
error : this.error
});
您可能感興趣的文章:
- jQuery實(shí)現(xiàn)鼠標(biāo)滑過(guò)鏈接控制圖片的滑動(dòng)展開(kāi)與隱藏效果
- jQuery實(shí)現(xiàn)鼠標(biāo)經(jīng)過(guò)時(shí)出現(xiàn)隱藏層文字鏈接的方法
- jQuery響應(yīng)鼠標(biāo)事件并隱藏與顯示input默認(rèn)值
- jQuery 網(wǎng)易相冊(cè)鼠標(biāo)移動(dòng)顯示隱藏效果實(shí)現(xiàn)代碼
- 基于JQuery實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊文本框顯示隱藏提示文本
- 基于jquery鼠標(biāo)點(diǎn)擊其它地方隱藏層的實(shí)例代碼
- jQuery實(shí)現(xiàn)表單input中提示文字value隨鼠標(biāo)焦點(diǎn)移進(jìn)移出而顯示或隱藏的代碼
- jquery插件實(shí)現(xiàn)鼠標(biāo)隱藏
相關(guān)文章
用Jquery實(shí)現(xiàn)滾動(dòng)新聞
此文主要用Jquery實(shí)現(xiàn)滾動(dòng)新聞,Jquery的強(qiáng)大功能,幾行代碼即可實(shí)現(xiàn),需要的朋友可以參考下2014-02-02
jQuery往textarea中光標(biāo)所在位置插入文本的方法
這篇文章主要介紹了jQuery往textarea中光標(biāo)所在位置插入文本的方法,實(shí)例分析了jQuery操作光標(biāo)及文本的相關(guān)技巧,需要的朋友可以參考下2015-06-06
jquery+正則實(shí)現(xiàn)統(tǒng)一的表單驗(yàn)證
表單驗(yàn)證一直很繁瑣,特別是大點(diǎn)的表單,如果每個(gè)input都去單獨(dú)寫(xiě)驗(yàn)證簡(jiǎn)直要寫(xiě)死人,最近寫(xiě)了一小段js統(tǒng)一的驗(yàn)證表單內(nèi)容是否正確。需要的朋友可以參考下2015-09-09
easyui下拉框動(dòng)態(tài)級(jí)聯(lián)加載的示例代碼
本篇文章主要介紹了easyui下拉框動(dòng)態(tài)級(jí)聯(lián)加載的示例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-11-11
基于jQuery.validate及Bootstrap的tooltip開(kāi)發(fā)氣泡樣式的表單校驗(yàn)組件思路詳解
這篇文章主要介紹了基于jQuery.validate及Bootstrap的tooltip開(kāi)發(fā)氣泡樣式的表單校驗(yàn)組件的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起看下吧2016-07-07

