Javascript examples for jQuery Selector:checked
The :checked selector selects all checked checkboxes or radio buttons.
The following code shows how to select all checked elements (checkboxes or radio buttons):
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(":checked").wrap("<span style='background-color:red'>"); });//from ww w . j a va 2 s . co m </script> </head> <body> <form action=""> Name: <input type="text" name="user"><br> bike: <input type="checkbox" name="vehicle" value="Bike"><br> car: <input type="checkbox" name="vehicle" value="Car" checked="checked"><br> <input type="submit"> </form> </body> </html>