Google News
logo
jQuery - Interview Questions
How we can get the value of a radio button using Jquery?
When a radio button is selected addition check attribute is not added to it. You have to enter "checked".
 
Example :                                          
$(document).ready(function(){
    $("input[type='button']").on('click', function(){
       var radioValue = $("input[name='gender']:checked").val();
       if(radioValue){
          alert(radioValue);
       }
    });
}); 
Advertisement