jquery에서 체크된 체크박스의 순서 가져오기(index) > jquery

본문 바로가기

jquery

jquery에서 체크된 체크박스의 순서 가져오기(index)

작성일 18-10-18 11:02

페이지 정보

작성자서방님 조회 278회 댓글 0건

본문

jquery 에서 화면에 표기된 체크박스중에 선택된 체크박스만을 가져와서 해당 체크박스의 속성과 값을 추출해 낼수 있습니다.


// 체크박스 중 체크된 체크박스만 가져와서 Loop 합니다.
$("input:checkbox[name=cart_prd_seq]:checked").each(function(i,elements){
    // 해당 index(순서)값을 가져옵니다.
    index = $(elements).index("input:checkbox[name=cart_prd_seq]");
    // 해당 index에 해당하는 체크박스의 ID 속성을 가져옵니다.
    alert($("input:checkbox[name=cart_prd_seq]").eq(index).attr("id"));
    // 해당 index에 해당하는 체크박스의 값을 가져옵니다.
    alert($("input:checkbox[name=cart_prd_seq]").eq(index),val());
});


위와 같은 방법을 사용하면 선택된 체크박스의 index 값을 조회하여 hidden으로 되어 있는 inputbox 의 값 또한 같이 조회할 수 있습니다.

댓글목록

등록된 댓글이 없습니다.

게시물 검색
Copyright © 서방님.kr All rights reserved.
PC 버전으로 보기