How to Uncheck All Checkboxes Using jQuery

To ubcheck all checkboxes in jQuery, we make use of prop() function with attribute value selector.  This function is only available in jQuery 1.6 or higher.  For jQuery 1.5 or lower, please make use of attr() function.  Example is given below for jQuery 1.6 or higher.

<!DOCTYPE html>
<html>
<head>
<title>jQuery Tutorial </title>
 
<script src="http://code.jquery.com/jquery-latest.js"></script>
 
<script type="text/javascript">
 
//Function to Check checkbox.
function CheckAll(){
    
    $('[type="checkbox"]').prop("checked", true) ;
 }

//Function to Uncheck checkbox.
function UncheckAll(){
    
    $('[type="checkbox"]').prop("checked", false) ;
 } 
</script>
 
</head>
<body>
 
My Checkbox:
<input  type="checkbox" /><input  type="checkbox" /><input  type="checkbox" />
<input type="button" value="Check" onclick="CheckAll()"/>
<input type="button" value="Uncheck" onclick="UncheckAll()"/>

</body>
</html>