티스토리 뷰

':eq(index)'는 선택된 요소들을 인덱스 번호로 찾을 수 있는 선택자.

마치 배열의 인덱스로 값(value)를 찾는 것과 같음.


원문 링크  http://api.jquery.com/eq-selector/


<table class="" id="tempList">

<colgroup>

<col width="">

<col width="">

<col width="">

</colgroup>

<thead>

<tr>

<th class="">컬럼헤더0</th>

<th class="">컬럼헤더1</th>

</tr>

</thead>

<tbody>

<tr>

<td>컬럼0</td>

<td>컬럼1</td>

</tr>

</tbody>

</table>


위와 같이 테이블이 있다면


테이블 row를 클릭했을때 값을 가져오려면


jquery로


$("#tempList tbody").on("click", "tr", function(){

alert( $(this).find("td:eq(0)").text() );

alert( $(this).find("td:eq(1)").text() );

});


td:eq(0) -> 선택(클릭)한 row의 첫번째 데이터 -> 컬럼0

td:eq(1) -> 선택(클릭)한 row의 두번째 데이터 -> 컬럼1



댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함