Dlaczego w moim kodzie js wystarczy jedno kliknięcie na name:check_all
zaznaczenie wszystkich pól wyboru?zaznaczenie wszystkich pól wyboru jquery
HTML:
<div id="ss">
<input type="checkbox" name="check_all">
</div>
<input type="checkbox" name="checked" class="idRow">
<input type="checkbox" name="checked" class="idRow">
<input type="checkbox" name="checked" class="idRow">
<input type="checkbox" name="checked" class="idRow">
<input type="checkbox" name="checked" class="idRow">
<input type="checkbox" name="checked" class="idRow">
<input type="checkbox" name="checked" class="idRow">
<input type="checkbox" name="checked" class="idRow">
jQuery:
$(document).on('click change','input[name="check_all"]',function() {
var checkboxes = $('.idRow');
if($(this).is(':checked')) {
checkboxes.attr("checked" , true);
} else {
checkboxes.attr ("checked" , false);
}
});
DEMO:http://jsfiddle.net/KdaZr/
Moja wersja jQuery 1.9.
Jak to naprawić?
Słodki Jezu, tyle kodu, gdy wszystko, co musisz zrobić, to: https://jsfiddle.net/4e8h7q7b/ – NullUserException