JQuery Radio Button Checked

JQuery Radio Button Checked

JQuery Radio Button Checked.

To get value of checked radio button from group of Radio buttons we will use Jquery script. We will group the radio button by giving common name attribute to all radio buttons. This way it will ensures that only one radio button get selected.

The name given to Group of Radio button is "RadioButtonListDemo"

$('input:radio:[name=RadioButtonListDemo]:checked').val();

It finds the radio buttons with group name "RadioButtonListDemo" and returns the value of it.

JQuery script to find selected radio button list item value.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    <script type="text/javascript" language="javascript">
       
    
    $(document).ready( function (){ 
    
        $("#button1").click( function(){
          
          var inputValue = $('input:radio:[name=RadioButtonListDemo]:checked').val();
           
    
            $("#Text1").val( inputValue  );
    
         });
                        
     });
    
    </script>
Html elements

<div> <input id="Radio1" name="RadioButtonListDemo" type="radio" value="Jquery" />Jquery <input id="Radio2" name="RadioButtonListDemo" type="radio" value="Asp.net"/>Asp.net <input id="Radio3" name="RadioButtonListDemo" type="radio" value="C#.net"/>C#.net <input id="Radio4" name="RadioButtonListDemo" type="radio" value="VB.net"/>VB.net <input id="Radio5" name="RadioButtonListDemo" type="radio" value="Linq"/>Linq <input id="Radio6" name="RadioButtonListDemo" type="radio" value="Example"/>Example <br /><br /> <input id="button1" type="button" value="Click To Get Selected value" /> <br /> You selected: <input id="Text1" type="text" />

</div>

How to uncheck checked radio button?

$('input:radio:[name=RadioButtonListDemo]').attr('checked',false);

Here we first find the radio button list by name and adds attribute checked = false. It will reset the selection of Radio button.

Tags:

Jquery Radio Button CheckedLearning JqueryBasics of jqueryJquery button click eventJquery Trim StringJQuery Animate Div Height and WidthJQuery SlideCheckbox Check all GridviewAndroid Button onClickListener ExampleJquery Dropdown Selected ValueJQuery add/remove Class Dynamically

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.