有關jquery彈出層

來源:互聯網
上載者:User

標籤:style   http   color   io   os   java   ar   div   sp   

http://www.jb51.net/article/35216.htm   源地址

 

今天用到了 JQuery 彈出層,看了很多東西, 對於其他的用外掛程式的還得下載,想了想 還得下載,

於是就 找了個只用這個的JQuery/javascript 的代碼, 自我感覺用起來方便

 

那麼 這個網址就給自己留著吧~

 

 

 


<!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=utf-8" /> 
<title>無標題文檔</title> 
<style> 
body{margin:0px;padding:0px} 
#div1{background:#F00;color: #FFF; display:none;position:absolute;} 
#div2{background:#333333;color: #FFF;width:400px;display:none; position:absolute;} 
</style> 
<Script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script> 
//瀏覽器視窗垂直置中 
<!-- 
<Script type="text/javascript"> 
function popup(popupName){ 
var _scrollHeight = $(document).scrollTop(),//擷取當前視窗距離頁面頂部高度 
_windowHeight = $(window).height(),//擷取當前視窗高度 
_windowWidth = $(window).width(),//擷取當前視窗寬度 
_popupHeight = popupName.height(),//擷取彈出層高度 
_popupWeight = popupName.width();//擷取彈出層寬度 
_posiTop = (_windowHeight - _popupHeight)/2 + _scrollHeight; 
_posiLeft = (_windowWidth - _popupWeight)/2; 
popupName.css({"left": _posiLeft + "px","top":_posiTop + "px","display":"block"});//設定position 
} 
$(function(){ 
$(".btn1").click(function(){ 
popup($("#div1")); 
}); 
$(".btn2").click(function(){ 
popup($("#div2")); 
}); 
}); 
</script> 
--> 
//當前視窗垂直置中 
<Script type="text/javascript"> 
function popup(popupName){ 
_windowHeight = $(".wrap").height(),//擷取當前視窗高度 
_windowWidth = $(".wrap").width(),//擷取當前視窗寬度 
_popupHeight = popupName.height(),//擷取彈出層高度 
_popupWeight = popupName.width();//擷取彈出層寬度 
_posiTop = (_windowHeight - _popupHeight)/2; 
_posiLeft = (_windowWidth - _popupWeight)/2; 
popupName.css({"left": _posiLeft + "px","top":_posiTop + "px","display":"block"});//設定position 
} 
$(function(){ 
$(".btn1").click(function(){ 
popup($("#div1")); 
}); 
$(".btn2").click(function(){ 
popup($("#div2")); 
}); 
}); 
</script> 
</head> 
<body > 
<div > 
<input class="btn1" type="button" value="1"/></div> 
<input class="btn2" type="button" value="2"/></div> 
<div style="width:500px; background:#ccc; position:relative; top:100px; left:200px;" class="wrap"> 
我是當前視窗啊我是當前視窗啊我是當前視窗啊我是當前視窗啊我是當前視窗啊我是當前視窗啊<br>我是當前視窗啊我是當前視窗啊我是當前視窗啊<br>我是當前視窗啊我是當前視窗啊我是當前視窗啊<br>我是當前視窗啊我是當前視窗啊我是當前視窗啊<br>我是當前視窗啊我是當前視窗啊我是當前視窗啊 
<br>我是當前視窗啊我是當前視窗啊我是當前視窗啊我是當前視窗啊 
<div id="div1">我是快顯視窗1111啊<br>我是快顯視窗1111啊<br>我是快顯視窗1111啊<br>我是快顯視窗1111啊<br>我是快顯視窗1111啊<br>我是快顯視窗1111啊<br>我是快顯視窗1111啊</div> 
<div id="div2">我是快顯視窗2222啊<br>我是快顯視窗2222啊<br>我是快顯視窗2222啊<br>我是快顯視窗2222啊<br>我是快顯視窗2222啊</div> 
</div> 
</body> 
</html> 

 

有關jquery彈出層

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.