Home >>jQuery Tutorial >jQuery checkbox Selector

jQuery checkbox Selector

jQuery checkbox Selector

jQuery checkbox selector in jQuery is used to selects input elements with type=checkbox.

Syntax:
$(":checkbox")
Here is an Example of jQuery :checkbox Selector

<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:#c0ed1f'>");
});
</script>
</head>
<body>
<form action="">
Name: <input type="text" name="user"><br>
checkbox 1: <input type="checkbox" name="vehicle" value="Bike"><br>
checkbox 2: <input type="checkbox" name="vehicle" value="Car"><br>
checkbox 3: <input type="checkbox" name="vehicle" value="Airplane"><br>
<input type="submit">
</form>
</body>
</html>

Output:
Name:
checkbox 1:
checkbox 2:
checkbox 3: