xxxxxxxxxx
// Set the default state of radio buttons
$('input[name="option"]').prop('checked', false);
// Add a change event listener to all radio buttons
$('input[name="option"]').on('change', function() {
// Get the selected value
var selectedValue = $('input[name="option"]:checked').val();
// Perform actions based on the selected value
if (selectedValue === 'option1') {
// Code to be executed when option1 is selected
} else if (selectedValue === 'option2') {
// Code to be executed when option2 is selected
} else if (selectedValue === 'option3') {
// Code to be executed when option3 is selected
}
});
xxxxxxxxxx
$('input:radio[name=sex]:nth(0)').attr('checked',true);
or
$('input:radio[name=sex]')[0].checked = true;