Check and Uncheck all checkbox using jQuery Example

Check and Uncheck all checkbox using jQuery Example

In this tutorial, i will show you simple jquery script to check and uncheck all checkboxes on one click.

This script is very short and useful for your application. You can use it whenever you need this type of functionality.

Lets assume you have a record list and you want to perform database update or delete action then you can use this script to select all records or multiple records to do for same activity.

You ever noticed that most of the websites use this functionality to select all items on page using single select all features.

We can achieve this task by using jquery prop() method.

The prop() method is used to retrieve property values of the selected elements.

  1. <html lang="en">
  2. <head>
  3.     <title>Select and deselect all checkboxes using jquery</title>
  4.     <script src=""></script>
  5. </head>
  6. <body>
  7. <ul>
  8.     <li><input name="product_all" class="checked_all" type="checkbox">Select All</li>
  9.     <li><input value="1" name="product" class="checkbox" type="checkbox">Product 1 </li>
  10. <li> <input value="2" name="product" class="checkbox" type="checkbox">Product 2 </li>
  11. <li><input value="3" name="product" class="checkbox" type="checkbox">Product 3 </li>
  12. <li><input value="4" name="product" class="checkbox" type="checkbox">Product 4 </li>
  13. <li><input value="5" name="product" class="checkbox" type="checkbox">Product 5 </li>
  14. </ul>
  15. <script type="text/javascript">
  16.      $('.checked_all').on('change', function() {     
  17.              $('.checkbox').prop('checked', $(this).prop("checked"));          
  18.         });
  19.         //deselect "checked all", if one of the listed checkbox product is unchecked amd select "checked all" if all of the listed checkbox product is checked
  20.         $('.checkbox').change(function(){ //".checkbox" change
  21.             if($('.checkbox:checked').length == $('.checkbox').length){
  22.          $('.checked_all').prop('checked',true);
  23.          }else{
  24.               $('.checked_all').prop('checked',false);
  25.          }
  26.         });
  27. </script>
  28. </body>
  29. </html>

Phone: (+91) 8800417876
Noida, 201301
ataşehir escort maltepe escort bostancı escort kadıköy escort maltepe escort ataşehir escort tuzla escort pendik escort ümraniye escort kartal escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort
hatay escort nevsehir escort nigde escort kirikkale escort batman escort osmaniye escort kirklareli escort tokat escort rize escort adiyaman escort gumushane escort batman escort
porno izle
cialis satış cialis fiyat cialis 20 mg cialis 100 mg cialis 5 mg fiyat
sohbet okey oyna
ankara escort marmaris escort bursa escort mersin escort antalya escort izmir escort samsun escort bodrum escort çeşme escort kuşadası escort adana escort eskişehir escort gaziantep escort esenyurt escort pendik escort tuzla escort fatih escort ümraniye escort mecidiyeköy escort kartal escort bahçelievler escort bahçeşehir escort ataşehir escort bakırköy escort nişantaşı escort avcılar escort büyükçekmece escort kurtkoy escort konya escort beşiktaş escort taksim escort beylikdüzü escort malatya escort sakarya escort şişli escort maltepe escort kadıköy escort ataköy escort bostancı escort şirinevler escort bağcılar escort üsküdar escort etiler escort başaksehir escort ortaköy escort kağıthane escort sultangazi escort halkalı escort çekmeköy escort şaşkınbakkal escort mamak escort sincan escort keçiören escort çankaya escort beypazarı escort akyurt escort pursaklar escort kahramankazan escort göztepe escort alsancak escort bornova escort buca escort karabaglar escort karşıyaka escort konak escort narlıdere escort izmit escort başiskele escort kandira escort körfez escort karamürsel escort dilovası escort gölcük escort gebze escort kocaeli escort kayseri escort elazığ escort denizli escort diyarbakir escort adana escort ankara escort izmir escort antalya escort gaziantep escort kayseri escort konya escort mersin escort denizli escort kocaeli escort diyarbakır escort