Get value of radio button using jQuery

Posted: June 8th, 2009 | Author: | Filed under: Javascript | Tags: , | 4 Comments »

Here’s a tutorial on how to get the value of a checked or selected radio button out of a group of radio buttons:

...
<input type="radio" name="sample" value="1" />
<input type="radio" name="sample" value="2" checked="checked" />
<input type="radio" name="sample" value="3" />
...

//javascript code

<script type="text/javascript">
<!--
    // displays the selected radio button in an alert box
    alert($('input[name=sample]:checked').val())
-->
</script>

4 Comments on “Get value of radio button using jQuery”

  1. 1 vinay said at 12:24 pm on September 14th, 2009:

    hey…Thanks alot..after a long search..this was very useful..!!

  2. 2 vinay joshi said at 1:03 pm on November 20th, 2009:

    thanks using this my big problem is solved

  3. 3 thanks said at 6:48 pm on October 2nd, 2010:

    thanks it ran in single attempt…………

  4. 4 M. Keijzer said at 11:44 am on October 9th, 2010:

    Thank you, very helpful!


Leave a Reply