 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery :checkbox Selector
The jQuery :checkbox selector is used to select input elements with type checkbox.
Syntax
The syntax is as follows −
$(":checkbox")  Example
Let us see an example to implement the :checkbox selector in jQuery −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script>    $(document).ready(function(){       $(":checkbox").wrap("<span style='border: 2px green dashed'>");    }); </script> </head> <body> <h2>Fill the form</h2> <form action=""> ID: <input type="text" name="id"><br> Rank: <input type="text" name="rank"><br> Fav. Subjects: Maths: <input type="checkbox" name="sub" value="maths"> English <input type="checkbox" name="sub" value="english"><br> <input type="submit" value="Submit"><br> </form> </body> </html> Output
This will produce the following output −

Example
Let us see another example −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script>    $(document).ready(function(){       $(":checkbox").wrap("<span style='background-color: orange'>");    }); </script> </head> <body> <h2>Hobbies</h2> <form action=""> Player Name: <input type="text" name="name"><br> Fav Sports Football: <input type="checkbox" name="sp" value="football"> Cricket <input type="checkbox" name="sp" value="cricket"><br><br> <input type="submit" value="Submit"><br> </form> </body> </html> Output
This will produce the following output −

Advertisements
 