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

  • SEARCH
  • Home
  • 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 829173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:50:25+00:00 2026-05-15T03:50:25+00:00

hi i try to check/uncheck all checkboxes that don’t got a class to them.

  • 0

hi i try to check/uncheck all checkboxes that don’t got a class to them. This is the code I got but it check the class boxes to.

$(document).ready(function() {
        $('#ctl00_ContentPlaceHolder1_repReceivers_ctl00_chxAll').click(
         function() {
        if (!$("input[type='checkbox']").hasClass("testclass")) {
             $("input[type='checkbox']").attr('checked', $('#ctl00_ContentPlaceHolder1_repReceivers_ctl00_chxAll').is(':checked'));
         }});
    });

any ideas where I go wrong?

EDIT
This suck but asp.net add a span around the checkbox input when given a cssclass, so the checkbox itself dont get the class. I tried to do like you say but like .not(thecheckboxid) but no luck.

EDIT CODE

<span class="testclass"><input id="ctl00_ContentPlaceHolder1_chxMale" type="checkbox" name="ctl00$ContentPlaceHolder1$chxMale" /></span>
  • 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-05-15T03:50:26+00:00Added an answer on May 15, 2026 at 3:50 am

    You need to modify your code a bit, like this (updated for updated question):

    $(function() {
      $('#ctl00_ContentPlaceHolder1_repReceivers_ctl00_chxAll').click(function() {
        $(":not(.testclass) > input[type='checkbox']").attr('checked', this.checked);
      });
    });
    

    Currently you’re checking if the first matched checkbox has the class, you want to filter out all those without the class from the batch you’re setting the checked property on. There are a few methods to do this, but :not() or .not() are the easiest here. The other change above is that since you’re inside an event handler for the _chxAll checkbox, you can use this instead of repeating the ID, it’s shorter and faster 🙂 With this you can use the .checked DOM property as well.

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

Sidebar

Related Questions

I commit all my files into bitbucket. i try check in,revert file i deleted
try: spam.foo except AttributeError: do_somthing() (Is it wise to check an attribute like that
I am trying to check some checkboxes based on it value. In my code,
I try to check multiple values in ASP.NET CheckboxList but I couldn't. I Wrote
I want to check and uncheck (toggle) the radio when td is click but
I have this Code of Showing all Records to a Message box using string
I'm writting some code in which I try to check every number in a
I have checkbox control on gridview with the ability to check all and uncheck
Hi i want to check all items of a listview.For that I am using
So, I try to check if passwords match. This is the encryption I use,

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.