Get value of radio button using jQuery

Posted: June 8th, 2009 | Author: admin | Filed under: Javascript | Tags: , |

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>

2 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


Leave a Reply