Ecco il mio codice:come contare ogni controllati caselle
In realtà conta caselle controllato e scrivere dentro <span class="counter"></span>
. Questo codice funziona su Firefox, ma non su Chrome.
Su Chrome, il segno .seleziona seleziona tutte le caselle di controllo che desidero, ma non aggiorna il contatore. In realtà il contatore si aggiorna quando deseleziono il .select_all, il che è strano.
fatto importante: Non voglio contare le caselle .Select_all dentro la mia .counter
jQuery(document).ready(function($){
$(function() {
$('#general i .counter').text(' ');
var generallen = $("#general-content input[name='wpmm[]']:checked").length;
if(generallen>0){$("#general i .counter").text('('+generallen+')');}else{$("#general i .counter").text(' ');}
})
$("#general-content input:checkbox").on("change", function() {
var len = $("#general-content input[name='wpmm[]']:checked").length;
if(len>0){$("#general i .counter").text('('+len+')');}else{$("#general i .counter").text(' ');}
});
$(function() {
$('.select_all').change(function() {
var checkthis = $(this);
var checkboxes = $(this).parent().next('ul').find("input[name='wpmm[]']");
if(checkthis.is(':checked')) {
checkboxes.attr('checked', true);
} else {
checkboxes.attr('checked', false);
}
});
});
});
EDIT: Ecco un documento esempio del codice: http://jsfiddle.net/8PVDy/1/
perché non provare semplice javascript – polin
Si può fornire un lavoro [jsFiddle] (http://jsfiddle.net) che illustra il problema? –
vedi questo post..http: //stackoverflow.com/questions/8011556/how-to-count-check-boxes-using-jquery – Rinku