Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

this.checked cannot be modified with checkbox click

It seems that the checked property of a checkbox cannot be modified, when the event is from the checkbox itself.
Here is small example:

<input type="checkbox" onclick="this.checked=true; return false">

The checkbox is not checked after click. Why is this.checked=true ignored?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It’s happening because you’re returning false. This value is assigned as the input value. Try this way:

<input type="checkbox" onclick="this.checked=true">
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading