国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

JQuery彈出層示例可自定義

2024-05-06 16:06:15
字體:
來源:轉載
供稿:網友
JQuery實現的彈出層,js和css可根據自己的實際情況而定,下面是具體的實現代碼,大家不妨參考下

1、創建一個jsp頁面,內容如下,js和css根據自己的實際情況而定

復制代碼 代碼如下:


<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<link href="Share.css" type="text/css">
<script type="text/javascript" src="../js/common/jquery-1.11.0.js"></script>
<script type="text/javascript" src="popup.js"></script>
<script type="text/javascript" src="testPopup.js"></script>

</head>
<body>
<div>
<div>
<h1>用戶管理</h1>
<a href="#">添加</a>
</div>
<div></div><!-- 將彈出層下面的頁面變成不可操作狀態,成半透明狀態 -->
<div>,<!-- 隱藏div -->
<div>
<h1>添加</h1>
<a href="#"><img src="close.png" /></a>
</div>
<div>

<table cellspacing="0" cellpadding="0">
<tr>
<td>姓名:</td>
<td><input type="text"
onfocus="this.className='input220L';this.onmouseout=''"
onblur="this.className='input220';this.onmouseout=function(){this.className='input220'};"
onmousemove="this.className='input220Lg'"
onmouseout="this.className='input220'"> <font color="red">*</font></td>
</tr>
<tr>
<td>昵稱:</td>
<td><input type="text"
onfocus="this.className='input220L';this.onmouseout=''"
onblur="this.className='input220';this.onmouseout=function(){this.className='input220'};"
onmousemove="this.className='input220Lg'"
onmouseout="this.className='input220'"> <font color="red">*</font></td>
</tr>
<tr>
<td>賬號:</td>
<td><input type="text"
onfocus="this.className='input220L';this.onmouseout=''"
onblur="this.className='input220';this.onmouseout=function(){this.className='input220'};"
onmousemove="this.className='input220Lg'"
onmouseout="this.className='input220'"> <font color="red">*</font></td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>


2、公用的帶有彈出層和關閉層的兩個方法

復制代碼 代碼如下:


//popup layer
function isIE(num){
var num = num || "",
tester = document.createElement('div');
tester.innerHTML = '<!--[if IE ' + num + ']><i></i><![endif]-->';
return !!tester.getElementsByTagName('i')[0];
}
function popupLayer(objClass,targetClass){
$("."+objClass).click(function(){
$("#spm").show();
var target=$("."+targetClass);
var targetWidth=target.outerWidth();
var targetHeight=target.outerHeight();
if(isIE(6)){
$("#spm").hide();
//$("select").hide();
var top=$(document).scrollTop()+$(window).height()/2;
target.css({"top":top+"px"});
$(window).scroll(function(){
var top=$(document).scrollTop()+$(window).height()/2;
target.css({"top":top+"px"});
});
}
target.css({"margin-top":-parseInt(targetHeight/2)+"px","margin-left":-parseInt(targetWidth/2)+"px"});
target.show();
return false;

});

}
//隱藏div的操作
function closeLayer(objClass,targetClass)
{
$("."+objClass).click(function(){
$(this).parents("."+targetClass).hide();
$("#spm").hide();

});
}


3、1中調用3中js實現效果的js代碼

復制代碼 代碼如下:


$(function(){
//第一個參數是按鈕的class屬性值,第二個是被隱藏的div屬性值
popupLayer("but_tj","Popup");
closeLayer("Close","Popup");
});

//我們通過點擊添加或修改按鈕后使當前操作的div隱藏
//closeAdd("Popup");
function closeAdd(targetClass){
$("."+targetClass).hide();
$("#spm").hide();
}


4、css樣式

復制代碼 代碼如下:


html {min-height: 100%;position: relative;overflow: hidden;}
body {background-color: #FFF;font: 12px 微軟雅黑, Arial, sans-serif;margin: 0;}
h1 {font-size: 12px;font-size: inherit;font-weight: normal;}
a {text-decoration: none;}
a:hover {text-decoration: none;}
.clear {overflow: hidden;clear: both;}
#right {margin-left: 190px;min-height: 100%;padding: 0;}
.right_top {height: 40px;background-color: #f5f5f5;color: #666666;border-bottom: 1px solid #e5e5e5;line-height: 40px;padding-left: 50px;position: relative;z-index: 1;}
.right_top a {color: #2b7dbc;}
.right_nav {margin: 0 30px;height: 37px;background-color: #438eb9;line-height: 37px;position: relative;margin-top: 15px;}
.right_nav h1 {font-size: 18px;color: #ffffff;padding-left: 20px;}
.but_tj {width: 68px;height: 27px;display: block;position: absolute;top: 7px;right: 30px;background: url(but_JG.png) no-repeat;text-align: center;line-height: 27px;font-size: 14px;color: #FFF;}
.but_tj:hover {background: url(but_JG1.png) no-repeat;}
.pind20 {padding-left: 20px;}
/*Popup*/
.Popup {width: 770px;height: 500px;position: absolute;left: 50%;top: 50%;margin-left: -400px;padding: 0 15px;margin-top: -250px;background-color: #FFF;border: 3px solid #006caa;z-index: 999;}
.Popup_top {height: 40px;line-height: 40px;border-bottom: 1px solid #cccccc;}
.Popup_top h1 {float: left;font-size: 14px;}
.Close {float: right;font-family: Arial, Helvetica, sans-serif;margin-right: 10px;margin-top: 10px;}
.Popup_cen {padding-top: 10px;width: 100%;height: 440px;overflow: auto;}
.Popup_audit {padding-top: 10px;width: 100%;height: 440px;}
.overlay {position: fixed;z-index: 990;width: 100%;height: 100%;top: 0;left: 0;filter: alpha(opacity = 60);opacity: 0.6;overflow: hidden;background-color: #000;}
/*BD_tab*/
.BD_tab {width: 500px;margin: 0 auto;}
.BD_tab td {padding-top: 12px;}
.input220,.input220L,.input220Lg {width: 220px;height: 28px;border: 1px solid #d3d3d3;padding-left: 5px;line-height: 28px;font-family: "微軟雅黑";color: #000;}
.input220L {border: 1px solid #377bcb;background-color: #d5e8ff;}
.input220Lg {border: 1px solid #7fb1eb;background-color: #d8e6f7;}
.input220 {border: 1px solid #d3d3d3;}


效果如下圖

JQuery彈出層示例可自定義

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 天峻县| 蚌埠市| 杭州市| 微博| 嫩江县| 兴隆县| 江口县| 永和县| 临颍县| 龙门县| 深圳市| 普兰县| 隆子县| 临泽县| 乌鲁木齐市| 罗定市| 额济纳旗| 永昌县| 临泉县| 玉门市| 托里县| 濮阳市| 武安市| 东兰县| 绥滨县| 南汇区| 大埔县| 类乌齐县| 芮城县| 山丹县| 雷州市| 万全县| 青河县| 华蓥市| 南华县| 宜城市| 西宁市| 通城县| 迭部县| 格尔木市| 张家口市|