You can check or uncheck a checkbox element or a radio button using the .prop() method:
// Check #x
$( "#x" ).prop( "checked", true );
// Uncheck #x
$( "#x" ).prop( "checked", false );
f you’re working with just one element, you can always just access the underlying HTMLInputElement and modify its .checked property
$('.x')[0].checked = true;
$('.x')[0].checked = false;
jQuery 1.5.x and below
$('.x').attr('checked', true);
$('.x').attr('checked', false);
Read More : Setting “checked” for a checkbox with jQuery
Top comments (0)