$('#radio-button-id').click(function() {
if($('#radio-button-id').is(':checked'))
{
//input where you put a value
$('#program').val("radio-button-text");
}
});
//true if checked and false if not
$("#radio").is(':checked');
$('#element').click(function() {
if($('#radio_button').is(':checked')) { alert("it's checked"); }
});
$('input:radio[name="postage"]').change(function(){
if ($(this).val() == 'Yes') {
//true
}
else {
//false
}
});
$(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!');
}
});
});
if ($('input[type="radio"]:checked').length) {
// do something
}
!$("input:radio[value='7'][name='employee-type']").prop('checked')
//<input type="radio" name="book_condition" value="3" >
$("input:radio[value='3'][name='book_condition']").prop('checked',true);
/*
A quick way to check if a radio button as been checked is by using
the .is(":checked") fucntion. A small example below :)
*/
var myElem = jQuery('#elemId'); // select the radio element
var testResult = myElem.is(":checked"); // returns true if checked, else false
$("#myRadioID").click();