Un deuxième pense-bête, sur le champ "checkbox"

Soit le code HTML suivant:

<input type="checkbox" name="haricot" /> Haricot
<input type="checkbox" name="carotte" /> Carotte
<input type="checkbox" name="champignon" /> Champignon

Savoir si un checkbox est coché

$('input:checkbox[name=haricot]').is(':checked');

Cocher / décocher une checkbox

$('input:checkbox[name=haricot]').attr('checked', true);

Parcourir les checkbox cochés

$("#formLegumes input[type=checkbox]:checked")
.each(function(){
     console.log($(this));
});

 


Warning: Parameter 2 to modChrome_artblock() expected to be a reference, value given in /var/www/bidoum.fr/templates/bleu/html/modules.php on line 39

Warning: Parameter 3 to modChrome_artblock() expected to be a reference, value given in /var/www/bidoum.fr/templates/bleu/html/modules.php on line 39