How can I know which radio button is selected via jQuery?

Explanation

You can know which radio button is selected via jQuery If you already have a reference to a radio button group.

Here we will take an example for this:

var myRadio = $("input[name=myRadio]");

Always use the filter() function, not find() when you have to know which radio button is selected.

 Because find()  the function is for locating child/descendant elements.  So whereas filter() searches top-level elements in your selection.

var checkedValue = myRadio.filter(":checked").val();

 

 

Also read, Convert bytes to a string

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *