The :checked selector to you can get radio button value in jQuery. The :checked selector works for checkboxes, radio buttons, and selected item options. To return only the selected options for the selected items, use :selected selection.
Sometimes we need to find the selected amount of radio button on a click-through event or change the event in jQuery. is very small but if you can easily find the amount of radio button per class or id at a jQuery click event. we need to use the radio button for men and women in our own way.
Get Radio Button Value JQuery
Example : 1
Get selected radio box value jQuery by class.
d radio box value jQuery by class. <!DOCTYPE html> <html> <head> <title>How to get selected radio button value in jQuery</title> <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> </head> <body> <input type="radio" name="sex" class="gender" value="male"> Male <input type="radio" name="sex" class="gender" value="female"> Female <button>Click to redirect</button> <script type="text/javascript"> $("button").change(function(){ var selValue = $(".gender:checked").val(); console.log(selValue); }); </script> </body> </html>
Example : 2
Get radio button value jQuery by id.
<!DOCTYPE html> <html> <head> <title>How to get selected radio button value in Jquery</title> <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> </head> <body> <input type="radio" name="sex" id="gender" value="male"> Male <input type="radio" name="sex" id="gender" value="female"> Female <button>Click to redirect</button> <script type="text/javascript"> $("button").change(function(){ var selValue = $("#gender:checked").val(); console.log(selValue); }); </script> </body> </html>
Example : 3
Get radio box value jQuery by name.
<!DOCTYPE html> <html> <head> <title>How to get selected radio button value in Jquery</title> <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> </head> <body> <input type="radio" name="sex" value="male"> Male <input type="radio" name="sex" value="female"> Female <button>Click to redirect</button> <script type="text/javascript"> $("button").change(function(){ var selValue = $("input[type='radio']:checked").val(); console.log(selValue); }); </script> </body> </html>