<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<link rel="stylesheet" href="css/bootstrap.css" type="text/css">
<style>
html,body{
height: 100%;
}
#bg{
z-index: 5;
position: fixed;
width:100%;
height: 100%;
left:0;
top:0;
background-color: rgba(0, 0, 0, 0.7);
display:none;
}
#table{
z-index: 10;
position: absolute;
top: 50px;
bottom: 50px;
left: 100px;
right: 100px;
background: #fff;
border-radius:5px;
overflow:auto;
display:none;
}
#table .tableTitle{
height: 50px;
padding: 15px;
box-sizing: border-box;
background-color: #f1f2f3;
}
#table .tableTitle h4{
line-height: 0;
}
#tableChart{
height: 420px;
margin: 20px auto 0;
}
#table table.table-floor{
z-index: 15;
position: relative;
width:80%;
margin:60px auto;
left:0;
top:0;
}
#table p.closeP{
float: right;
font-size: 16px;
font-weight: bold;
cursor: pointer;
margin-top: -20px;
}
#table p.closeP>i{
color: #aaa;
}
#table p.closeP>i:hover{
color:#000;
}
</style>
<body>
<span οnclick="a(1,2,1,1);">1111111</span>
<div id="bg">
</div>
<div id="table">
<div class = "tableTitle">
<h4>这里是标题</h4>
<p class = "closeP" onclick = "closeP();"><i class = "icon-remove"></i></p>
</div>
<div id="tableChart">
<table class = "table table-bordered table-floor" id = "tableContent">
</table>
</div>
</div>
</body>
<script type="text/javascript">
function a(id,name,total,num) {
// body...
$.ajax({
type:"POST",
url:"",
dataType:"json",
data:{id:id,name:name,total:total,num:num},
success:function(){
alert("成功");
},
error:function () {
var item = [];
$.each([1,2,3,4,5],function(i){
var str = "<tr>";
$.each([1,2,3,4,5],function(j,value){
str += "<td>" + j + value + "</td>";
});
str += "</tr>";
// console.log(str);
item.push(str);
});
item = item.join("");
// console.log(item);
var item = $(item);
$("#tableContent").append(item);
}
});
$("#bg").show();
$("#table").show();
}
function closeP() {
$("#tableContent").empty();
$("#bg").hide();
$("#table").hide();
}
</script>
<script src="js/jquery.min.js"></script>
</html>
jquery实现遮罩层
最新推荐文章于 2024-04-04 00:43:04 发布