Want a free Ebook & latest Update Subscribe Now
  [email protected]      beta
Donate

How to Get Selected Radio Button Value in jQuery

 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

Share:    
Satinder Singh

Hi all, am Founder and Author of Codepedia.info, also atypical polyglot programmer from Bombay, India. I have a passion to create, solve, and deploy software applications.
       ForEach ( minute in MyLife ) { myExperience++ ; }