- 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
jQuery Examples - $(":checked")
Description
"$(":checked")" Selects all checked check boxes in the form.
Syntax
Here is the simple syntax to use this selector −
$(":checked")
Parameters
Here is the description of all the parameters used by this selector −
:checked − checked check box selector
Returns
This selector returns an array filled with the checked elements.
Example
<html> <head> <title>The Selector 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"> $(document).ready(function() { /* Selects the visible <li> element..*/ $(":checked").wrap( "<span></span>" ).parent().css("background-color", "yellow"); }); </script> </head> <body> <form> <table> <tr><td>Name</td><td><input type = "text"></td></tr> <tr><td>Password</td><td><input type = "password"></td></tr> <tr><td>Gender</td> <td><input type = "radio" name = "gender" value = "male">Male<br/> <input type = "radio" name = "gender" value = "female">Female</td> </tr> <tr><td>Food</td> <td><input type = "checkbox" name = "chinese" value = "chinese" checked>Chinese<br/> <input type = "checkbox" name = "indian" value = "indian">Indian</td> </tr> </table> </form> </body> </html>
This will produce following result −
jqueryexamples_selectors.htm
Advertisements
To Continue Learning Please Login
Login with Google