首页 > 代码库 > 查找表格最后一列,并且添加删除和修改按钮

查找表格最后一列,并且添加删除和修改按钮

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<script src="http://www.mamicode.com/javascript/jquery-1.11.1.min.js"></script>
<body>
<table height="70" width="700" border="1px">
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td></td>
</tr>
</table>
<script>
var str=$();
$(‘table tr‘).each(function(i,q){
var item=$(q).find(‘td:last‘);
str=str.add(item);
});
str.append(‘<button>删除</button><button>修改</button>‘)
</script>
</body>
</html>

查找表格最后一列,并且添加删除和修改按钮