lundi 27 juin 2016

removeAttribute('checked') not working

I encounter a strange problem concerning checkboxes. For various reasons I have to programmaticaly check or uncheck checkbox inputs depending on the context of my application.

But for an unknown reason I unable to uncheck the checkbox. Searching on the internet teach me to remove the "checked" attribute in order to uncheck the box, as "checked" is a binary attribute : Check/Uncheck checkbox with javascript? and Remove attribute "checked" of checkbox

None of these subjects (and many other that I read) are useful in my case : I don't want to use jQuery, so the logical way to do the same is to use removeAttribute function, just like that :

document.getElementById('box').removeAttribute('checked');

It seems to be executed but no effect is visible.

My code is a bit to complex and huge to post it here, so I made a more relevant jsFiddle to show you the problem : http://ift.tt/293S3bc

By using the buttons, whatever the state of the box is, you can see that the button used to check the box is working, whereas the button to uncheck is not.

Any ideas for make it work or find a workaround ? Thanks.




Aucun commentaire:

Enregistrer un commentaire