checkbox selector in jQuery with example
Checkbox selector returns all input elements with type checkbox.
Example 1 :
<html>
<head>
<title>checkbox 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()
{
$(":checkbox:nth(2)").attr("checked","checked");
});
});
</script>
</head>
<body>
<input type="checkbox" name="BE" id="Qualification">BE
<input type="checkbox" name="ME" id="Qualification">ME
<input type="checkbox" name="BSC" id="Qualification">BSC
<input type="checkbox" name="MBA" id="Qualification">MBA
<button id="myButton">Click Me</button>
<button onclick="location.reload();">Reset</button>
</body>
</html>
Demo :
In the above example, we have used checkbox selector. Checkbox selector return all input elements with type checkbox. In the above example the checkbox selector selects the third checkbox on button click and checks it.
0 comments:
Post a Comment