mardi 11 octobre 2016

jQuery checkbox to array working in console but not in javascript

i have this checkboxes on my html page

<label for="fatturato">Classe di Fatturato:</label>
                <form id="fatturato">
                    <label class="checkbox">
                        <input type="checkbox" class="fatturatoCheck" value="F0">0 - 499.999
                    </label>

                </form>

and i need to get an array with the checked options.

In order to doing this in my .js i have wrote

        var fatturato = $('input:checkbox:checked.fatturatoCheck').map(function () {
        return this.value;
    }).get();

but it isn't workin, it gives me and empty array. If i paste it chrome console it works fine!




Aucun commentaire:

Enregistrer un commentaire