[상용 jQuery 코드 세그먼트] checkbox 전체 선택/역선택
1096 단어 jquery
html
- 1
- 2
- 3
- 4
- 5
jQuery 코드:
jQuery$(function() { $("#clickAll").click(function() { if ($("#clickAll").prop("checked")) { $("input[name='user_active_col[]']").each(function() { $(this).prop("checked", true); }); } else { $("input[name='user_active_col[]']").each(function() { $(this).prop("checked", false); }); } }); });
demo
참고: jQuery 1.6 이후에attr 대신 prop을 사용합니다.