1.index9.css
@CHARSET "UTF-8";
.odd{
background: red;
}
.even{
background: green;
}
2.index9.jsp
<%@ page language="java" import="java.util.*"pageEncoding="UTF-8"%>
<%
Stringpath = request.getContextPath();
StringbasePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index4.jsp' startingpage</title>
<meta http-equiv="pragma"content="no-cache">
<meta http-equiv="cache-control"content="no-cache">
<meta http-equiv="expires"content="0">
<meta http-equiv="keywords"content="keyword1,keyword2,keyword3">
<meta http-equiv="description"content="This is my page">
<link rel="stylesheet"type="text/css" href="css/index9.css">
<script type="text/javascript"src="plug/jquery.js"></script>
</head>
<body>
<table width="200px"height="100px" border="1">
<tr>
<td>编号</td>
<td>姓名</td>
<td>成绩</td>
</tr>
<tr>
<td>001</td>
<td>小明</td>
<td>80</td>
</tr>
<tr>
<td>002</td>
<td>张三</td>
<td>79</td>
</tr>
<tr>
<td>003</td>
<td>小吕</td>
<td>90</td>
</tr>
<tr>
<td>004</td>
<td>谢云</td>
<td>77</td>
</tr>
</table>
<script type="text/javascript">
$(function() {
"tr:odd").addClass("odd");
"tr:even").addClass("even");
});
</script>
</body>
</html>


运行效果如下:


在table表格中奇偶行数样式的改变_css