Tutorialspoint.dev

jQuery | :checkbox Selector

The checkbox is a very important element to make interactions with a user. In JQuery, we can build a simple checkbox to allow data entry as well.

Syntax:

$(":checkbox")

We can implement the checkbox in the code:
Example:

<!DOCTYPE html>
<html>
  
<head>
    <script src=
  </script>
      
  <style>
        p {
            font-size: 20px
        }
    </style>
    <script>
        $(document).ready(function() {
            $(":checkbox").wrap(
            "<span style='background-color:green'>");
        });
    </script>
</head>
  
<body>
  
    <h2>Add your Hobbies:</h2>
    <p>Dancing:
        <input type="checkbox"
               name="hobbies" 
               value="dancing">
        <br> Painting:
        
        <input type="checkbox"
               name="hobbies"
               value="painting">
        <br> Singing:
        
        <input type="checkbox"
               name="hobbies" 
               value="singing">
        <br>
    </p>
  
</body>
  
</html>

Output:



This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter