How to Get Selected Radio Button Value in jQuery

satinder singh / Updated : / 0 Comments

 jquery get radio button value: This article explains how to check whether the radio button is checked or unchecked or getting the selected radio button value. In this post will explain how to check status of radio button i.e. whether radio button is checked or unchecked in jQuery. Here we use .is() method and matched checked attribute.

Description: .is() Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

HTML:

//*
<input name="gender" type='radio' id='rdoMale'>Male
<input name="gender" type='radio' id='rdoFemale'>Female
<button id="btnGenderStatus">Click me</button>
//*

 JQUERY:

//*
var rdM = $("#rdoMale");
var rdF = $("#rdoFemale");
$("#btnGenderStatus").on('click', function () {
    if ($(rdM).is(":checked")) {
        console.log("You selected Male");
    } else if ($(rdF).is(":checked")) {
        console.log("You selected female");
    }
});
//*

VIEW DEMO