radio selector in jQuery with example
Radio selector returns all input elements with type radio.
Example :
<html>
<head>
<title>radio Selector</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
<script type="text/javascript">
$(document).ready(function()
{
$("#myButton").click(function()
{
$(":radio[name=Gender]:nth(0)").attr("checked","checked");
});
});
</script>
</head>
<body>
Male<input type="radio" name="Gender" id="male">
Female<input type="radio" name="Gender" id="female">
<button id="myButton">Click Me</button>
<button onclick="location.reload()">Reset</button>
</body>
</html>
Demo :
In the above example, we have used radio selector. Radio selector return all input elements with type radio. In the above example the radio selector selects the first radio button.
0 comments:
Post a Comment