Last updated Feb 17, 2021

Check/Uncheck All Checkboxes with jQuery (Select All Example)

Learn how to select or deselect all checkboxes using jQuery. A quick guide with practical examples for handling form inputs easily.

Check/Uncheck All Checkboxes with jQuery (Select All Example)

Howdy Coders,

In this post, we are going to see how to check-uncheck all checkboxes using jQuery.

It becomes useful when you want to allow users to select or deselect all checkboxes at once by clicking one checkbox rather than selecting one by one checkbox Just like Amazon, Flipkart like size uses for its product filtering.

Steps by step Guide to select/Deselect checkbox using jQuery:

If you are new to Jquery or want to learn some basic before starting this tutorial, I must recommend to please checkout learn-javascript-from-scratch and jquery-step-by-step-tutorial-for-beginners

So, here I am going to show how this can be done by using Jquery. It can become handy and I have also used it on many projects and it's working great for me.

So let’s start.

STEP-1:

First of all, you have to add the jquery library to your page:



STEP-2:

Create a Blank HTML file and put the following code:


Check/Uncheck all checkbox with Jquery
Select All Items
Item-1
Item-2
Item-3
Item-4
Item-5
Item-6

STEP-3:

After ending the HTML tag add some Javascript code including with script tag as follow:

Now you are done. If you find any issue checkout the complete source code given below:

Complete source code:

Index.html




    


Check/Uncheck all checkbox with Jquery
Select All Items
Item-1
Item-2
Item-3
Item-4
Item-5
Item-6

CSS:

html, body {
   margin:0;
   padding:0;
   height:100%;
}
body {
	border: 0;
	color: #000;
}

#body{
	width: 500px;
    margin: 0 auto;
    max-width: 100%;
	padding:20px 0 70px 0;
	height: 100%;
}

#container {
   min-height:100%;
   position:relative;
}

.header{
    font-size: 25px;
    text-align: center;
    background-color: #d0dafd;
}
table {
    *border-collapse: collapse;
    border-spacing: 5px;
    width: 100%;
}

.bordered {
    border: solid darkgoldenrod 3px;
    box-shadow: 0 1px 1px darkgoldenrod;
}

.bordered td {
    padding: 10px;
    border-bottom: 2px solid #d0dafd;

}
.bordered th {
    padding: 10px;
    border-bottom: 2px solid darkgoldenrod;
    background-color: #eee;
    border-top: none;
    text-align:center;
}

.bordered tbody tr:nth-child(even) {
	background: #eeeeee;
	border:1px solid #000;

}
.bordered tbody tr:hover td {
	background: #d0dafd;
	color: #FF0000;
}
tr td {
    text-align: center;
}

Conclusion:

Thanks for reading.

Do let me know If you face any difficulties please feel free to comment below we love to help you. if you have any feedback suggestions then please inform us by commenting.

Don’t forget to share this tutorial with your friends on Facebook and Twitter.

Tags

Available for projectsLet’s build together

Need this built properly,
not just explained?

I take on Angular and NestJS work directly — auth systems, multi-tenant SaaS, API rewrites and the deploy pipeline underneath them. You talk to the person writing the code.

Projects delivered
20+ Projects delivered
Angular • NestJS
7+ years Angular • NestJS
Average reply time
1 day Average reply time

What I can help with

  • Auth and permissions systems
  • Multi-tenant SaaS foundations
  • API design and rewrites
  • Deploy pipelines and VPS setup
  • Bug fixing and performance optimization
Send me a message

Tell me about your project and I’ll get back with a realistic scope and price.

Turn
Your Ideas
Into Reality

Stay in the loop

Get the finished tutorials, projects and resources in your inbox.

Join 5,000+ developers and get new tutorials, source code, product updates and exclusive content — straight to your inbox.

  • No spam
  • Useful content only
  • Unsubscribe anytime

Subscribe to TutsCoder

Be the first to get new tutorials, projects and tips.

Join 5,000+ developers already learning with us.

Learn
Build
Grow

Discussion

Comments

Share your thoughts, ask questions or suggest improvements. Let’s learn and grow together!

Loading comments…

Join the discussion

Sign in to join the discussion. Your account also keeps your saved tutorials and path progress.