How do I check/uncheck a checkbox input or radio button?

jQuery

How do I check/uncheck a checkbox input or radio button?

You can check or uncheck a checkbox element or a radio button using the .prop() method:

1
2
3
4
5
                          
// Check #x
$("#x").prop( "checked", true );
// Uncheck #x
$("#x").prop( "checked", false );