Jquery遮罩层

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">

<title>Jquery遮罩层</title>

<style type="text/css">
#BgDiv {
	background-color: #e3e3e3;
	position: absolute;
	z-index: 99;
	left: 0;
	top: 0;
	display: none;
	width: 100%;
	height: 1000px;
	opacity: 0.5;
	filter: alpha(opacity = 50);
	-moz-opacity: 0.5;
}

#DialogDiv {
	position: absolute;
	width: 400px;
	left: 50%;
	top: 50%;
	margin-left: -200px;
	height: auto;
	z-index: 100;
	background-color: #fff;
	border: 1px #8FA4F5 solid;
	padding: 1px;
}

#DialogDiv h2 {
	height: 25px;
	font-size: 14px;
	background-color: #8FA4F5;
	position: relative;
	padding-left: 10px;
	line-height: 25px;
}

#DialogDiv h2 a {
	position: absolute;
	right: 5px;
	font-size: 12px;
	color: #000000
}

#DialogDiv .form {
	padding: 10px;
}

#DialogDiv2 {
	position: absolute;
	width: 400px;
	left: 50%;
	top: 50%;
	margin-left: -200px;
	height: auto;
	z-index: 100;
	background-color: #fff;
	border: 1px #8FA4F5 solid;
	padding: 1px;
}

#DialogDiv2 h2 {
	height: 25px;
	font-size: 14px;
	background-color: #8FA4F5;
	position: relative;
	padding-left: 10px;
	line-height: 25px;
}

#DialogDiv2 h2 a {
	position: absolute;
	right: 5px;
	font-size: 12px;
	color: #000000
}

#DialogDiv2 .form {
	padding: 10px;
}

#DialogDiv3 {
	position: absolute;
	width: 400px;
	left: 50%;
	top: 50%;
	margin-left: -200px;
	height: auto;
	z-index: 100;
	background-color: #fff;
	border: 1px #8FA4F5 solid;
	padding: 1px;
}

#DialogDiv3 h2 {
	height: 25px;
	font-size: 14px;
	background-color: #8FA4F5;
	position: relative;
	padding-left: 10px;
	line-height: 25px;
}

#DialogDiv3 h2 a {
	position: absolute;
	right: 5px;
	font-size: 12px;
	color: #000000
}

#DialogDiv3 .form {
	padding: 10px;
}
</style>

<script language="javascript" type="text/javascript"
	src="http://www.cydiguo.com/static/js/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
	function ShowDIV(thisObjID) {
		$("#BgDiv").css({
			display : "block",
			height : $(document).height()
		});
		var yscroll = document.documentElement.scrollTop;
		$("#" + thisObjID).css("top", "100px");
		$("#" + thisObjID).css("display", "block");
		document.documentElement.scrollTop = 0;
	}
	function closeDiv(thisObjID) {
		$("#BgDiv").css("display", "none");
		$("#" + thisObjID).css("display", "none");
	}
</script>

</head>

<body>
	<div id="BgDiv"></div>

	<!--遮罩层显示的DIV1-->
	<div id="DialogDiv" style="display: none">
		<h2>
			弹出层<a href="#" id="btnClose" οnclick="closeDiv('DialogDiv')">关闭</a>
		</h2>
		<div class="form">我是弹出对话框111111!!</div>
	</div>

	<!--遮罩层显示的DIV2-->
	<div id="DialogDiv2" style="display: none">
		<h2>
			弹出层<a href="#" id="btnClose2" οnclick="closeDiv('DialogDiv2')">关闭</a>
		</h2>
		<div class="form">我是弹出对话框2222!!</div>
	</div>

	<!--遮罩层显示的DIV3-->
	<div id="DialogDiv3" style="display: none">
		<h2>
			弹出层<a href="#" id="btnClose3" οnclick="closeDiv('DialogDiv3')">关闭</a>
		</h2>
		<div class="form">我是弹出对话框3333333!!</div>
	</div>

	<p>
		<input value="弹出遮罩层1" type="button" id="btnShow1"
			οnclick="ShowDIV('DialogDiv')" /> <input value="弹出遮罩层2"
			type="button" id="btnShow2" οnclick="ShowDIV('DialogDiv2')" /> <input
			value="弹出遮罩层3" type="button" id="btnShow3"
			οnclick="ShowDIV('DialogDiv3')" />
	</p>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jQuery遮罩层倒计时可以通过使用jQuery插件和Bootstrap来实现。你可以使用Bootstrap的模态框组件来创建遮罩层,并且使用jQuery的计时器功能来实现倒计时。 首先,你需要在页面中引入jQuery和Bootstrap的相关文件。然后,你可以按照下面的步骤来实现遮罩层倒计时: 1. 创建一个按钮或者其他触发事件的元素,当用户点击该元素时,触发倒计时和遮罩层的显示。 2. 使用jQuery的计时器功能来实现倒计时。你可以使用`setInterval`函数来设置一个定时器,每隔一定的时间更新倒计时的显示内容。 3. 在定时器的回调函数中,更新倒计时的显示内容,并根据剩余时间判断是否显示遮罩层。你可以使用jQuery选择器来获取遮罩层的元素,并使用`show`和`hide`函数来控制其显示和隐藏。 4. 当倒计时结束时,你可以触发弹出模态框(遮罩层)的操作。你可以使用`modal`方法来显示模态框。 这是一个简单的实现示例代码: ```html <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> </head> <body> <button id="startCountdown" class="btn btn-primary">开始倒计时</button> <div id="myModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">警告</h5> </div> <div class="modal-body"> <p>您的时间已经用完</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-success" data-dismiss="modal">确定</button> </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> <script> $(document).ready(function() { $("#startCountdown").click(function() { var countdown = 10; // 设置倒计时的秒数 var countdownTimer = setInterval(function() { countdown--; if (countdown <= 0) { clearInterval(countdownTimer); $("#myModal").modal("show"); // 显示模态框 } else { $("#countdownDisplay").text(countdown); // 更新倒计时显示 } }, 1000); }); }); </script> </body> </html> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值