给坐落表格第2列的所有单元格添加类样式

给位于表格第2列的所有单元格添加类样式;

 

        给一个表格的第二列添加背景色为red:

<html>
	<head>
		<title>td</title>
		<style type="text/css">
		.test{
			background:red;
		}
		</style>
	</head>
	<body>
		<table border=1px>
			<tr>
				<td>123</td>
				<td>456</td>
				<td>789</td>
			</tr>
			<tr>
				<td>aaa</td>
				<td>bbb</td>
				<td>ccc</td>
			</tr>
		</table> 
	</body>
</html>
<script src="jquery-1.9.1.js"></script>
<script>
	$("tr").each(function (){
		$(this).find('td:eq(1)').addClass("test");
	});
</script>

给坐落表格第2列的所有单元格添加类样式