jQuery Make Radio Button Checked or UnCheck By Example

jQuery Make Radio Button Checked or UnCheck By Example

How to get or selected radio checked button value. In this jquery tutorial, you will learn how to get selected or checked radio button value.

You can use the selector and val() method by jQuery Api and get the value of selected or radio input or button value.

We will use jQuery api method :checked selector for get or selected radio values. So you need to know that about jQuery api :checked selector

:checked selector Method By jQuery

Using the jQuery Api :checked selector method to get or return the value of selected HTML element.

$(“:checked”) Method Syntax


By Example jQuery $(“:checked”) method

This example will demostrate you how use jquery :checked selector method to selected html elements.

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Get Checked Radio Button Value</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
            var rVal = $(".rbtn:checked").val();
                alert("Your are a - " + rVal);
    padding: 15px;
    border: 12px solid #23384E;
    background: #28BAA2;
    margin-top: 10px;
    <div class="ctrCls">
    <h4>Please select your gender.</h4>
        <label><input type="radio" name="gender" value="male" class="rbtn">Male</label> 
        <label><input type="radio" name="gender" value="female" class="rbtn">Female</label>
    <p><input type="button" value="Get Value" id="btn-get"></p>


Get Checked Radio Button Value

Please select your gender.

Leave a Reply

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