mercredi 13 décembre 2017

Why is a newly created checkbox checked when I set checked to false?

When I put this code in my console, I end up with a checked box in my web page:

$('body').append($('<input/>', {
                                    type: 'checkbox',
                                    value: "foo",
                                    checked: false
                                }));

When I remove the checked attr altogether, the box is not checked:

$('body').append($('<input/>', {
                                    type: 'checkbox',
                                    value: "foo",                                       
                                }));

...but I need a dynamic set of checkboxes to be generated, some checked and some not. What attr/value creates the correct "unchecked" state?




Aucun commentaire:

Enregistrer un commentaire