xxxxxxxxxx
// Assuming you have a radio input element with the class 'myRadio'
var selectedValue = $('input[name="myRadio"]:checked').val();
xxxxxxxxxx
By LOVE
Here , name=Gender is the name attribute value of the radio button
$("input[name='Gender']:checked").val()
xxxxxxxxxx
$('#radio-button-id').click(function() {
if($('#radio-button-id').is(':checked'))
{
//input where you put a value
$('#program').val("radio-button-text");
}
});
xxxxxxxxxx
$('input:radio[name="postage"]').change(function(){
if ($(this).val() == 'Yes') {
//true
}
else {
//false
}
});
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>