mercredi 3 juin 2015

I want to get the values of all the checked checkboxes

$(document).ready(function() {
    $('input[type = "checkbox"]').change(function() { //when a checkbox is checked
        var nvalues = $('input[type="checkbox"]:checked').map(function() {
            return this.value;
        }).get();
        if (nvalues.length > 0) {
            var fin = nvalues.value;
            $('#here').html(fin);
        } else {
            $('#here').html("WTF");
        }
    });
});

here I'am storing the checked values as array using map but the output is empty.




Aucun commentaire:

Enregistrer un commentaire