<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/jquery-2.1.0.js"></script>
<script>
$(function(){
$(" input:eq(3)").click(function(){
var name=$(" input:eq(0)").val();
var pwd = $(" input:eq(1)").val();
var email = $(" input:eq(2)").val();
//创建单元格
var tdCheckbox = $("<td><input type='checkbox' /></td>");
var tdName=$("<td>"+name+"</td>");
var tdPwd=$("<td>"+pwd+"</td>");
var tdEmail = $("<td>"+email+"</td>");
var tdDel = $("<td><button>删除</button></td>");
var tr=$("<tr></tr>");
tr.append(tdCheckbox).append(tdName).append(tdPwd).append(tdEmail).append(tdDel);
$("tbody").append(tr);
$("tbody button").click(function(){
$(this).parent().parent().remove();
})
});
});
</script>
<style>
td{text-align: center;}
tr:nth-child(1){ background-color: pink;}
tr:nth-child(2){ background-color: lightskyblue;}
tr:nth-child(3){ background-color: orange;}
tr:nth-child(4){ background-color: purple;}
tr:nth-child(5){ background-color: black;}
tr:nth-child(6){ background-color: #FF3660;}
</style>
</head>
<body>
<center>
用户名:<input type="text" placeholder="请输入用户名" />
密 码:<input type="text" placeholder="请输入密码" />
邮 箱:<input type="text" placeholder="请输入邮箱" />
<input type="button" value="添加" /><br/><br/>
<table border="1px solid blue" cellspacing="0" cellpadding="10" width="1000px">
<thead >
<tr style="background-color: yellow;">
<th><input type="checkbox" /> </th>
<th>用户名</th>
<th>密 码</th>
<th>邮 箱</th>
<th>操 作</th>
</tr>
</thead>
<tbody>
<td><input type="checkbox" /></td>
<td >张三</td>
<td >123</td>
<td >QQ.com</td>
<td ><button>删除</button> </td>
</tbody>
</table>
</center>
</body>
</html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/jquery-2.1.0.js"></script>
<script>
$(function(){
$(" input:eq(3)").click(function(){
var name=$(" input:eq(0)").val();
var pwd = $(" input:eq(1)").val();
var email = $(" input:eq(2)").val();
//创建单元格
var tdCheckbox = $("<td><input type='checkbox' /></td>");
var tdName=$("<td>"+name+"</td>");
var tdPwd=$("<td>"+pwd+"</td>");
var tdEmail = $("<td>"+email+"</td>");
var tdDel = $("<td><button>删除</button></td>");
var tr=$("<tr></tr>");
tr.append(tdCheckbox).append(tdName).append(tdPwd).append(tdEmail).append(tdDel);
$("tbody").append(tr);
$("tbody button").click(function(){
$(this).parent().parent().remove();
})
});
});
</script>
<style>
td{text-align: center;}
tr:nth-child(1){ background-color: pink;}
tr:nth-child(2){ background-color: lightskyblue;}
tr:nth-child(3){ background-color: orange;}
tr:nth-child(4){ background-color: purple;}
tr:nth-child(5){ background-color: black;}
tr:nth-child(6){ background-color: #FF3660;}
</style>
</head>
<body>
<center>
用户名:<input type="text" placeholder="请输入用户名" />
密 码:<input type="text" placeholder="请输入密码" />
邮 箱:<input type="text" placeholder="请输入邮箱" />
<input type="button" value="添加" /><br/><br/>
<table border="1px solid blue" cellspacing="0" cellpadding="10" width="1000px">
<thead >
<tr style="background-color: yellow;">
<th><input type="checkbox" /> </th>
<th>用户名</th>
<th>密 码</th>
<th>邮 箱</th>
<th>操 作</th>
</tr>
</thead>
<tbody>
<td><input type="checkbox" /></td>
<td >张三</td>
<td >123</td>
<td >QQ.com</td>
<td ><button>删除</button> </td>
</tbody>
</table>
</center>
</body>
</html>