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 6342313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:13:04+00:00 2026-05-24T20:13:04+00:00

I have several checkboxes spread across two divs. The two divs are contained in

  • 0

I have several checkboxes spread across two divs. The two divs are contained in a div called actions.
In a separate div I have a ‘select all’ checkbox. When that checkbox is selected, I am trying to get all the other ones to be selected, and when you deselect the ‘select all’ one, it deselects the others.

This is the HTML:

<div class="actions" id="actions" title="Actions">
    <div>
        <div><input type="checkbox" name="action" class="act" value="0" /> <?php echo $lang["actions"][0]; ?></div><br />
        <div><input type="checkbox" name="action" class="act" value="1" /> <?php echo $lang["actions"][1]; ?></div><br />
        <div><input type="checkbox" name="action" class="act" value="2" /> <?php echo $lang["actions"][2]; ?></div><br />
        <div><input type="checkbox" name="action" class="act" value="3" /> <?php echo $lang["actions"][3]; ?></div><br />

    </div>
    <div>
        <div><input type="checkbox" name="action" class="act" value="26" /> <?php echo $lang["actions"][26]; ?></div><br />
        <div><input type="checkbox" name="action" class="act" value="27" /> <?php echo $lang["actions"][27]; ?></div><br />
        <div><input type="checkbox" name="action" class="act" value="28" /> <?php echo $lang["actions"][28]; ?></div><br />
        <div><input type="checkbox" name="action" class="act" value="29" /> <?php echo $lang["actions"][29]; ?></div><br />
        <div><input type="checkbox" name="action" class="act" value="30" /> <?php echo $lang["actions"][30]; ?></div><br />
        <div><input type="checkbox" name="action" class="act" value="31" /> <?php echo $lang["actions"][31]; ?></div>
    </div>
</div>
<div class="parameters1">
    <div class="selectAll" title="Select All"><input type="checkbox" id="selectAll" name="selectall" /> Select All</div>
</div>

Here is my JQuery:

$(".selectAll").click(function() {
        var checked_status = this.checked;
        $('#actions').find("input").each(function() {
            $(this).attr(":checked", checked_status);
        });
});

If I put an alert() inside the each function, it is seeing every single check box correctly, however the $(this).attr bit does not seem to be actually changing the checkbox.

Any ideas?

  • 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-24T20:13:05+00:00Added an answer on May 24, 2026 at 8:13 pm

    You’re not setting the attribute properly:

        $(this).prop("checked", checked_status);
    

    Starting with the 1.6 version of jQuery, “.prop()” is preferred over “.attr()” for this purpose, though for a boolean attribute/property like “checked” the “.attr()” function will still work. The attribute name does not need the “:” on the front, and in fact that will make the operation fail since the property you want to update is in fact called “checked”, without a “:”.

    Also you don’t really need the explicit “.each()”; it should work fine to do:

        $('#actions input').prop('checked', checked_status);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML form spread across several divs. I need to know when
I have several checkboxes in php which are contained in a table: <table> <tr>
I have a GET form with checkboxes. When i select several boxes and submit
i have several checkboxes that when checked show a hidden div. Is there a
I have several forms, all which require a checkbox for each province/state. Therefore, I've
I have a form which contains several checkboxes align vertically in a div. I
I have several checkboxes and I am trying to take a lazy approach of
I have several checkboxes within a JForm(SubComponents) and I am using this code to
I have a search form where several checkboxes are checked by default. When the
I have several checkboxes and a fake submit button to make an AJAX request:

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.