When using radio buttons in web application we need to get value of radio buttons at clientside. We can use jQuery to get radio button value in jQuery.
Code that shows how to get radio button value in jQuery
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<title>Get radio button value</title>
<script type="text/javascript">
$(document).ready(function () {
$("#submit").click(function () {
var number = $("input[@name=numbers]:checked").val();
alert(number);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="radio" name="numbers" value="0" checked="checked" style="display:none" />
<input type="radio" name="numbers" value="1" />
<input type="radio" name="numbers" value="2" />
<input type="radio" name="numbers" value="3" />
<input id="submit" type="button" value="Submit"/>
</div>
</form>
</body>
</html>
Output