Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fronteer-kr/27065a4c46832a8248bc to your computer and use it in GitHub Desktop.
Save fronteer-kr/27065a4c46832a8248bc to your computer and use it in GitHub Desktop.
// 아래와 같은 HTML Table Code 를 가정하고
<table>
<thead>
<tr>
<th><input type="checkbox" name="_selected_all_"></th>
<th>제목</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" name="_selected_" value="ROW_1"></td>
<td>안녕하세요</td>
</tr>
<tr>
<td><input type="checkbox" name="_selected_" value="ROW_2"></td>
<td>반갑습니다</td>
</tr>
<tr>
<td><input type="checkbox" name="_selected_" value="ROW_3"></td>
<td>Good Luck!</td>
</tr>
</tbody>
</table>
//----------------------------------------------------------------------------
// 전체선택 및 해제 기능은..
$('input[name=_selected_all_]').on('change', function(){
$('input[name=_selected_]').prop('checked', this.checked);
});
//----------------------------------------------------------------------------
// 선택한 Checkbox 값을 가져오는 방법은...
var arr = $('input[name=_selected_]:checked').serializeArray().map(function(item) { return item.value });
//var str = $('input[name=_selected_]:checked').serialize(); // 이건 QueryString 방식으로
@secret1u
Copy link

ㅇㄹㄴㅇㄹ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment