[jQuery学习日志]二,是用选择器控制表格交替变色等
发布时间:2010-01-16 06:53:11,阅读人数:198
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head>
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<style type="text/css">
table{ width:800px; border-collapse: collapse; color: #999;}
table td{ padding: 6px 3px 6px 3px;}
.first_td{ border-bottom: 1px #D0D0D0 solid;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('tr:odd')//tr的奇数元素组合
.css("background","#EAEAEA");
$('tr:first>td')//第一个tr元素下面所有的td组合
.addClass("first_td").css("color","#666");
$('tr:last>td')//最后一个tr元素下面所有的td组合
.addClass("first_td");
})
</script>
<title>第二个jQuery代码</title>
<body>
<table>
<tr>
<td>标题1</td><td>标题2</td><td>标题3</td><td>标题4</td><td>标题5</td>
</tr>
<tr>
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
</tr>
<tr>
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
</tr>
<tr>
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
</tr>
<tr>
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
</tr>
</table></body>
</html>
我也要说两句
热门博文

