- jQuery Examples
- Examples - Home
- Examples - Set up
- Examples - Selectors
- Examples - Attributes
- Examples - Traversing
- Examples - CSS
- Examples - DOM
- Examples - Events
- jQuery Useful Resources
- jQuery - Quick Guide
- jQuery - Useful Resources
$("input:radio[name=bar]:checked").val()
Description
This gets the first value from a set of radio buttons.
Syntax
Here is the simple syntax to use this method −
selector.val();
Parameters
None
Example
Following example gets the first value from a set of radio buttons.
<html> <head> <title>The jQuery Example</title> <script type = "text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" language = "javascript"> function show(){ alert($("input:radio[name=bar]:checked").val()); } </script> </head> <body> <div> <form name = "sampleForm"> <input type = "radio" name = "bar" title="The jQuery Example" value = "red" >red</input><br/><br/> <input type = "radio" name = "bar" title="The jQuery Example" value = "green" >green</input> <br/><br/> <input type = "button" id = "submitButton" onclick="show();" value = "submit"/> </form> </div> </body> </html>
This will produce following result −
jqueryexamples_attributes.htm
Advertisements
To Continue Learning Please Login
Login with Google