jQuery實(shí)現(xiàn)的AJAX簡單彈出層效果代碼
更新時(shí)間:2015年11月26日 15:53:34 作者:Jimmy.Yang
這篇文章主要介紹了jQuery實(shí)現(xiàn)的AJAX簡單彈出層效果代碼,涉及jQuery響應(yīng)鼠標(biāo)事件動(dòng)態(tài)操作頁面元素實(shí)現(xiàn)彈出層效果的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了jQuery實(shí)現(xiàn)的AJAX簡單彈出層效果。分享給大家供大家參考,具體如下:
運(yùn)行效果截圖如下:

具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標(biāo)題文檔</title>
<script type="text/javascript" src="jquery1.3.2.js"></script>
<style type="text/css">
<!--
html, body
{
height: 100%;
margin: 0px;
font-size: 12px;
}
.mydiv
{
background-color: #FFCC66;
border: 1px solid #f00;
text-align: center;
line-height: 40px;
font-size: 12px;
font-weight: bold;
z-index: 99;
width: 300px;
height: 120px;
left: 50%; /*FF IE7*/
top: 50%; /*FF IE7*/
margin-left: -150px !important; /*FF IE7 該值為本身寬的一半 */
margin-top: -60px !important; /*FF IE7 該值為本身高的一半*/
margin-top: 0px;
position: fixed !important; /*FF IE7*/
position: absolute; /*IE6*/
_top: expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2); /*IE5 IE5.5*/
}
.mydiv2
{
background-color: #FFCC66;
border: 1px solid #f00;
text-align: center;
line-height: 40px;
font-size: 12px;
font-weight: bold;
z-index: 99;
width: 400px;
height: 400px;
left: 50%; /*FF IE7*/
top: 50%; /*FF IE7*/
margin-left: -200px !important; /*FF IE7 該值為本身寬的一半 */
margin-top: -200px !important; /*FF IE7 該值為本身高的一半*/
margin-top: 0px;
position: fixed !important; /*FF IE7*/
position: absolute; /*IE6*/
_top: expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2); /*IE5 IE5.5*/
}
.bg
{
background-color: #666;
width: 100%;
height: 100%;
left: 0;
top: 0; /*FF IE7*/
filter: alpha(opacity=50); /*IE*/
opacity: 0.5; /*FF*/
z-index: 1;
position: fixed !important; /*FF IE7*/
position: absolute; /*IE6*/
_top: expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2); /*IE5 IE5.5*/
}
-- ></style>
<script language="javascript" type="text/javascript">
function showDiv() {
$('#popDiv').removeClass().addClass("mydiv").css("display","block").css("background","ff9");
$('#bg').css("display","block");
}
function showDiv2() {
$('#popDiv').removeClass().addClass("mydiv2").css("display","block").css("background","pink");
$('#bg').css("display","block");
}
function closeDiv() {
$('#popDiv').css("display","none");
$('#bg').css("display","none");
}
</script>
</head>
<body onload="$('#bg').css('height',document.body.clientHeight).css('width',document.body.clientWidth); ">
<div id="popDiv" class="mydiv" style="display: none;">
動(dòng)態(tài)彈出的層<br />
動(dòng)態(tài)彈層的內(nèi)容<br />
<a href="javascript:closeDiv()">關(guān)閉窗口</a></div>
<div id="bg" class="bg" style="display: none;">
</div>
<div style="height: 1400px;">
<div style="text-align: center;">
<a href="javascript:showDiv()">點(diǎn)我1</a><br/><br/>
<a href="javascript:showDiv2()">點(diǎn)我2</a>
</div>
</div>
</body>
</html>
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:
- jQuery實(shí)現(xiàn)form表單基于ajax無刷新提交方法詳解
- JavaScript原生xmlHttp與jquery的ajax方法json數(shù)據(jù)格式實(shí)例
- jQuery使用$.ajax進(jìn)行異步刷新的方法(附demo下載)
- jQuery實(shí)現(xiàn)ajax調(diào)用WCF服務(wù)的方法(附帶demo下載)
- jQuery學(xué)習(xí)筆記之Ajax用法實(shí)例詳解
- Jquery操作Ajax方法小結(jié)
- 談?wù)刯Query Ajax用法詳解
- jQuery使用$.ajax進(jìn)行即時(shí)驗(yàn)證的方法
相關(guān)文章
jQuery監(jiān)聽瀏覽器窗口大小的變化實(shí)例
下面小編就為大家?guī)硪黄猨Query監(jiān)聽瀏覽器窗口大小的變化實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-02-02
jQuery 動(dòng)態(tài)云標(biāo)簽插件
這里推薦給大家一款jquery動(dòng)態(tài)云標(biāo)簽的插件,非常的炫,在指定塊級(jí)元素內(nèi)動(dòng)態(tài)生成a標(biāo)簽,a標(biāo)簽的高度、寬度、位置、層數(shù)、背景顏色隨機(jī)可控,a標(biāo)簽漸隱顯示和漸隱消失,可改變初始化的透明度,鼠標(biāo)懸浮停止動(dòng)畫且透明度最大,層數(shù)最高,鼠標(biāo)離開,恢復(fù)之前狀態(tài)2014-11-11
jquery彈窗時(shí)禁止body滾動(dòng)條滾動(dòng)的例子
今天小編就為大家分享一篇jquery彈窗時(shí)禁止body滾動(dòng)條滾動(dòng)的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-09-09
jQuery鼠標(biāo)移動(dòng)圖片上實(shí)現(xiàn)放大效果
這篇文章主要介紹了jQuery鼠標(biāo)移動(dòng)圖片上實(shí)現(xiàn)放大效果 ,需要的朋友可以參考下2017-06-06
jQuery實(shí)現(xiàn)基本淡入淡出效果的方法詳解
這篇文章主要介紹了jQuery實(shí)現(xiàn)基本淡入淡出效果的方法,結(jié)合實(shí)例形式詳細(xì)分析了jQuery使用fadeIn()、fadeOut()及fadeToggle()等方法控制頁面元素淡入淡出顯示效果的相關(guān)操作技巧,需要的朋友可以參考下2018-09-09

