Recent Posts

JQuery get selected radio button value

JQuery get selected radio button value

How to get user selected value in the radio button using JQuery.Here tested easy best methods to selected radio button value.
HTML code is here.

<input class="radioBtnClass" name="numbers" type="radio" value="1" />1
<input class="radioBtnClass" name="numbers" type="radio" value="2" />2
<input class="radioBtnClass" name="numbers" type="radio" value="3" />3

 

JQuery Code

if($("input[type='radio'].radioBtnClass").is(':checked')) {
   var selected_value =  $("input[type='radio'].radioBtnClass:checked").val();
   alert(selected_value);
}

 

This is also working.

$(".radioBtnClass").change(function(){
      // bind a function to the change event
        if( $(this).is(":checked") ){ // check if the radio is checked
            var selected = $(this).val(); // retrieve the value
            alert(selected_value);
        }
});

 

What's your reaction?

Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0

Comments are closed.

Next Article:

0 %