사용자 정의 선택기('선택기 필터(기본 필터)'를 사용해서...) - 테이블의 짝수번째 배경색 변경하기
[EvenOdd.htm]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>테이블의 짝수번째 배경색 변경</title>
<style type="text/css">
.greenColor { background-color:Green; }
.yellowColor { background-color:Yellow; }
</style>
<script src="js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
//[1] 홀수번째 배경색을 green으로 하고 싶다?
$('tr:odd').addClass('greenColor');
//[2] tr 태그 중 짝수번째 배경색을 Yellow로 하고자한다면?
$('table tr:even').addClass('yellowColor');
});
</script>
</head>
<body>
<table>
<tr>
<td>Windows Server(0번째 : 짝수)</td>
</tr>
<tr>
<td>SQL Server</td>
</tr>
<tr>
<td>Visual Studio</td>
</tr>
<tr>
<td>DotNetNuke Portal</td>
</tr>
</table>
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]