Last active
January 27, 2022 07:01
-
-
Save saltun/33a6f7e183abd45814cc5d1306b0ca58 to your computer and use it in GitHub Desktop.
Select All Checkboxes with jQuery example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Select All Checkboxes with jQuery - savascanaltun.com.tr</title> | |
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<center> | |
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"> | |
<label for="vehicle1"> I have a bike</label><br> | |
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car"> | |
<label for="vehicle2"> I have a car</label><br> | |
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat"> | |
<label for="vehicle3"> I have a boat</label><br> | |
<hr/> | |
<input type="checkbox" id="selectAll" name="" > | |
<label for="selectAll"> Select All</label> | |
</center> | |
<script type="text/javascript"> | |
$("#selectAll").click(function(){ | |
$("input[type=checkbox]").prop('checked', $(this).prop('checked')); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment