samedi 27 octobre 2018

JS: Setting checked to true is not working

Trying to set a Checkbox via addEventListener in JS, I already tried with

element.checked = true;
element.setAttribute('checked', true);
element.setAttribute('checked', "checked");

I can see in the console that my checked is set to true (not sure if the issue is that the boolean value is shown as string "true" or if this is just a chrome representation) but the element is not getting the check mark.

input id="element" class="element" name="element" type="checkbox" value="1" checked="true"

Onload the default checked box is correctly set but when I'm trying to uncheck and set the new one nothing is happening (visually).

Thanks for any help.




Aucun commentaire:

Enregistrer un commentaire