본문 바로가기

IT개발 과정 [취성패 학원]/jQuery

[jQuery] 04. 필터링관련선택자 및 메소드

필터 관련 선택자

  • $("대상:선택자")
<table border="1">
    <tr>
        <th>이름</th>
        <th>혈액형</th>
        <th>거주지</th>
    </tr>
    <tr>
        <td>홍길동</td>
        <td>A형</td>
        <td>서울</td>
    </tr>
    <tr>
        <td>김영희</td>
        <td>B형</td>
        <td>경기도</td>
    </tr>
    <tr>
        <td>김삼순</td>
        <td>O형</td>
        <td>부산</td>
    </tr>
    <tr>
        <th colspan="2">총인원</th>
        <td>3명</td>
    </tr>
</table>
<script>
	$(function(){
		$("tr:first").css("backgroundColor", "black").css("color", "white");
		$("tr:last").css({backgroundColor:"red", color:"white"});
		$("tr:even").css("backgroundColor", "lightgray");
		$("tr:odd").css("backgroundColor", "yellow");
	})
</script>

 

필터링과 관련된 메소드