노력하다
$(document).ready(function () {
$('.select_unselect_all').change(function () {
$('.se_unse').prop('checked', this.checked);
});
});
this.checked
확인란이 확인되었는지 여부를 알려줍니다. 부울 가치를 반환합니다.
문제
아래와 같은 HTML이 있습니다
<script>
$(document).ready(function(){
$('.select_unselect_all').click(function(){
console.log('hurray>>>');
$('.se_unse').prop('checked', true);
});
});
</script>
<table cellpadding="0" cellspacing="0" border="0" class="stdtable">
<thead>
<tr>
<th><input id="" class="select_unselect_all" type="checkbox"/></th>
<th>product name</th>
</tr>
</thead>
<tbody>
{% for val in values %}
<tr>
<td><input id="" class="se_unse" type="checkbox" /></td>
<td>{{val.name}}</td>
</tr>
{% endfor %}
</tbody>
</table>
위의 html 및 jQuery 코드에서 Class에서 Checkbox를 클릭하면 select_unselect_all
, 나머지 모든 확인란을 모두 입력했습니다 tbody
수업과 함께 차단하십시오 se_unse
선택해야합니다 (위의 jQuery 코드와 함께 작동).
그래서 우리가 클래스와 같은 동일한 확인란을 다시 클릭하면 select_unselect_all
안에 thead
점검 된 모든 확인란 섹션은 확인하지 않아야합니다
위의 코드에서 이것을 구현하는 방법은 무엇입니까?
해결책
노력하다
$(document).ready(function () {
$('.select_unselect_all').change(function () {
$('.se_unse').prop('checked', this.checked);
});
});
this.checked
확인란이 확인되었는지 여부를 알려줍니다. 부울 가치를 반환합니다.
다른 팁
이 시도:
$(function(){
$('.select_unselect_all').click(function(){
$('.se_unse').prop('checked', $(this).prop('checked'));
});
});