LearnFast.Ninja

jQuery radio button checked value example

How to get value of checked radio button using jQuery? Write this string then call val function. Test our Working Example code.

Step 1: Write this string then call val function.
$('input:radio[name=Rate_Group]:checked').val();

Working Example code:

<!DOCTYPE html>

<html>

<head>

    <title>Untitled Page</title>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>

    <script type="text/javascript">

        function Get_Value() {

            var Rate = $('input:radio[name=Rate_Group]:checked').val();

            alert(Rate);

        }

    </script>

</head>

<body>

    <input type="radio" name="Rate_Group" value="1" style="width: 40px;" />

    <input type="radio" name="Rate_Group" value="2" style="width: 40px;" />

    <input type="radio" name="Rate_Group" value="3" style="width: 40px;" checked="checked" />

    <input type="radio" name="Rate_Group" value="4" style="width: 40px;" />

    <input type="radio" name="Rate_Group" value="5" style="width: 40px;" />

    <br />

    <br />

    <a href="#" onclick="Get_Value();">Get Rate Value</a>

</body>

</html>

 

Result:


Tags

jquery

radio-button