IT개발 과정 [취성패 학원]/jQuery
[jQuery] 04. 필터링관련선택자 및 메소드
선영27
2021. 4. 21. 17:17
필터 관련 선택자
- $("대상:선택자")
<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>
필터링과 관련된 메소드
- 기준이 되는 요소 중에서 특정 요소만을 걸러서 선택해주는 메소드
- $("대상").필터링메소드()
- first(), last(), filter(), not(), eq(index)-인덱스지정
- [선택자 종류 참고] http://www.tcpschool.com/jquery/jq_elementSelection_jqSelector