1 2 3 4 | $(document).on( 'click' , '.click' , function (){ var what_num = $( this ).closest( 'tr' ).prevAll().length; alert(what_num); } |
.closet은 this 엘리먼트의 가장 가까운 tr를 탐색하고, .prevAll은 this 엘리먼트의 형제 모든 tr들을 가져와서 객체화 한다.
즉 tr 내부에 input이든, 뭐든 클릭할 때 tr 번째 수를 알 수 있다.
결과보기
'시바 | Jquery' 카테고리의 다른 글
JQuery select box 제어 모음 (0) | 2018.04.06 |
---|