JavaScriptJquery

Check All Checkbox Using Jquery

<html lang="en">
<head>
  <title>Select/DeSelect All Checkbox Using Jquery</title>  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
 <h1 class="text-success" align="center">Select/DeSelect All Checkbox Using Jquery</h1><br>
 
  <form align="center">
  <input type="checkbox" id="select_all" /> Select all
    <div class="checkbox">
      <label><input type="checkbox" class="checkbox" value="Option 1">Option 1</label>
    </div>
    <div class="checkbox">
      <label><input type="checkbox" class="checkbox" value="Option 2">Option 2</label>
    </div>
    <div class="checkbox disabled">
      <label><input type="checkbox" class="checkbox" value="Option 3">Option 3</label>
    </div>
  </form>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
    $('#select_all').on('click',function(){	
         $('input:checkbox').not(this).prop('checked', this.checked);
    });    
});
</script>
</html>

Related Articles

Check Also
Close
Back to top button