Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:10:30+00:00 2026-06-10T20:10:30+00:00

I was working on checkboxes operation using jQuery . I wrote a small snippet

  • 0

I was working on checkboxes operation using jQuery. I wrote a small snippet of code to make it work.

When I check selectAll check box, it should select all the checkboxes whilst when I un-check any of the check box it should un-check the “select all” one. And, the behavior should toggle.

Please check this code snippet Check – UnCheck

Somehow I’m not convinced with my code. Recommend if I can do it in a better way. TIA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:10:32+00:00Added an answer on June 10, 2026 at 8:10 pm
    $(function() {
        var elems = $('input[type="checkbox"]');
    
        elems.first().on('change', function() {
            $(this).siblings(elems).prop('checked', this.checked);
        }).end().not(':first').on('change', function() {
            elems.first()
                 .prop('checked', ((this.checked ? elems.length - 1 : elems.length) == $(elems)
                 .filter(':checked').length));
        });
    });​
    

    FIDDLE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a ASP.NET MVC3 code to bind the CheckBoxes using the
We have the following code working for a complex rails form with checkboxes. I'm
Working on a small game using an HTML5 canvas, and javascript. And it's working
I'm trying to show a small loading image during a slow operation with jQuery
I have 60 checkboxes with the name AG[] and i was using a check-all
I'm working with a list whose items are both selectable (using checkboxes) and sortable
I try to setup checkboxes and cannot get working simple code. Any clue? Thank
I am currently working on adding checkboxes to my website and adding some jquery
So I am working on cross-browser code right now. I have checkboxes, that disable
I am working on zend. I have a form with some checkboxes. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.