Posted on 29th April 2025|538 views
how to Set radio button 'checked' in jquery based on ID?
in my program, there are two radio buttons in which one radio button is checked by default. Still, my question is how to uncheck or check a radio button within jQuery when selecting by id the program is:
$(‘#radioA’).attr(‘checked’,’checked’);
$(‘#radioA’).attr(‘checked’,’true’);
Can you please help me?
Posted on 29th April 2025| views
We should not use the same id more than once instead we can use class
$(‘.radioA’).attr(‘checked’,’true’);
$(‘.radioB’).attr(‘checked’,’true’);
The id must be utilised one per the element per page
$('#id').click(function(){
$('#radioA').attr('checked', true);
});