<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
#bgDiv {
position: absolute;
left: 0px;
top: 0px;
background-color: black;
opacity: 0.2; /*设置不透明度,即可以看到层下面的内容,但是由于层的遮挡,是不可以进行操作的*/
display: none;
}
#fgDiv {
position: absolute;
width: 300px;
height: 100px;
border: 1px solid red;
background-color: #e7e7e7;
display: none;
}
</style>
<script src="scripts/jquery-1.7.1.js"></script>
<script>
var list = [
{ id: '1', country: '中国', capital: '北京' },
{ id: '2', country: '美国', capital: '华盛顿' },
{ id: '3', country: '日本', capital: '东京' },
{ id: '4', country: '韩国', capital: '首尔' }
];
$(function () {
$('#btnAdd').click(function () {
//显示添加界面
$('#bgDiv').css('display', 'block').css('width', window.innerWidth + 'px').height(window.innerHeight+'px');
$('#fgDiv').css('display', 'block').css('left', (window.innerWidth - 300) / 2 + 'px').css('top', (window.innerHeight - 100) / 2 + 'px');
//清除文本框中的数据
$('#fgDiv :text,:hidden').val('');
});
//生成表格数据
$.each(list, function () {
$('<tr />
</div>
</body>
</html>
相关文章: