xxxxxxxxxx
$('input:radio[name="postage"]').change(function(){
if ($(this).val() == 'Yes') {
//true
}
else {
//false
}
});
xxxxxxxxxx
$("input:radio[name=type]").click(function() {
alert('You clicked radio!');
alert($('input:radio[name=type]:checked').val());
if($('input:radio[name=type]:checked').val() == "walk_in"){
}
});
xxxxxxxxxx
$('#element').click(function() {
if($('#radio_button').is(':checked')) { alert("it's checked"); }
});
xxxxxxxxxx
$('#radio-button-id').click(function() {
if($('#radio-button-id').is(':checked'))
{
//input where you put a value
$('#program').val("radio-button-text");
}
});
xxxxxxxxxx
$(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!');
}
});
});
jQuery radio button is checked false
xxxxxxxxxx
$("#radio_1").prop("checked", false);
xxxxxxxxxx
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
// Attach click event handler to the button
$('#checkButton').on('click', function() {
// Get the value to check for (replace "option2" with your desired value)
var valueToCheck = 'option2';
// Loop through each radio option
$('input[type="radio"]').each(function() {
// Compare the current radio option's value with the value to check
if ($(this).val() === valueToCheck) {
// If there's a match, set the radio option as checked
$(this).prop('checked', true);
}
});
});
});
</script>