Saturday 24 December 2022

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 );

No comments:

Post a Comment