I have a dynamic radio button group. The names and Ids are dynamic. The issue I am having is that I am able to select multiple radio buttons at the same time because the names are different. I need to be able to select only one at a time. I assigned a class to the group and want to be able to select only one using the class name.
Tried this but it’s not working
$('.rClass').click(function () {
$('.rClass').prop("checked", false);
$(this).prop("checked", true);
});
but it’s not working. Can someone please show me what I am doing wrong here?
Thanks
2
Answers
To create a radio button group with jQuery and limit the user to selecting only one radio button at a time, you can use the following code:
Use event delegation on the nearest static ancestor of all the radio inputs.