jquery select a radio button code example
Example 1: jquery checkbox checked value
if ($('#check_id').is(":checked"))
{
}
Example 2: jQuery check a radio button
$("#myRadioID").prop("checked", true);
$("#myRadioID").attr('checked', 'checked');
Example 3: jquery select radio
$(function() {
var $radios = $('input:radio[name=gender]');
if($radios.is(':checked') === false) {
$radios.filter('[value=Male]').prop('checked', true);
}
});
Example 4: check radio button is checked jquery
$(document).ready(function(){
$('#submit_button').click(function() {
if (!$("input[name='name']:checked").val()) {
alert('Nothing is checked!');
return false;
}
else {
alert('One of the radio buttons is checked!');
}
});
});
Example 5: click on a radio button using jquery
$('input:radio[name=sex]:nth(0)').attr('checked',true);
or
$('input:radio[name=sex]')[0].checked = true;