Home >>jQuery Tutorial >jQuery checked Selector

jQuery checked Selector

jQuery checked Selector

jQuery checked selector in jQuery is used to selects all checked checkboxes or radio buttons.

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

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(":checked").wrap("<span style='background-color:lightgreen'>");
});
</script>
</head>
<body>
<form action="">
Name: <input type="text" name="user"><br>
selector 1: <input type="checkbox" name="vehicle" value="Bike"><br>
selector 2: <input type="checkbox" name="vehicle" value="Car" checked="checked"><br>
selector 3: <input type="checkbox" name="vehicle" value="Airplane"><br>
<input type="submit">
</form>
</body>
</html>

Output:
Name:
selector 1:
selector 2:
selector 3: