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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:46:55+00:00 2026-06-09T00:46:55+00:00

I am trying to make a DIV hide/show depending on whether a Checkbox is

  • 0

I am trying to make a DIV hide/show depending on whether a Checkbox is selected or not.

Multiple items are displayed in my site, each under a DIV called .itemBox. Some colors are shown in Checkbox and I would like to hide all items besides those of the color the user picks (depending on the chosen Checkbox).

My javascript should check the ID of each .itemBox items (which is a color) and then hide/show.

So far I have my form and javascript, but nothing happens when I check a Checkbox.

FORM:

div class="colors">
<?php
$colors = mysql_query("SELECT DISTINCT color_base1 FROM item_descr ORDER BY color_base1");
while ($colorBoxes = mysql_fetch_array($colors))
{
echo "<input type='checkbox' class='regularCheckbox' name='color' value='".$colorBoxes[color_base1]."' /><font class='similarItemsText'>   ".$colorBoxes[color_base1]."</font><br />";
}
?>
</div>

JAVASCRIPT:

<script>
    $('.colors').delegate('input:checkbox', 'change', function() { 
         if ($(this).attr('checked')) {
            $(".itemBox not(#" + $(this).val()  + ")").hide();
            $(".itemBox #" + $(this).val()).show();
        }
    })
</script>

OUTPUT:

<td><div name='item' id='".$info[color_base1]."' class='itemBox'> .....
  • 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-09T00:46:56+00:00Added an answer on June 9, 2026 at 12:46 am

    Here is how I would do it:

    $(":checkbox").bind("click", function (event) {
         if($(this).is(':checked')) {
              $(".itemBox:not(#" + $(this).val()  + ")").hide();
              $(".itemBox[id='" + $(this).val() + "']").show();
         }else {
               //maybe you should do smth if checkbox is unchecked
         }
    });
    

    I think your mistake was the space before :not and the second selector should be like $(“.itemBox[name=’value’]”) without space before [.

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

Sidebar

Related Questions

I'm trying to make a simple Click on Div -> Hide DIV -> Show
Trying to make a simple toggle menu, and I can't seem to hide/show the
So, I am trying to make floated divs to hide in parent's div, but
I'm trying to make a check box to show/hide a HTML element, but I
Hi I have been trying to make a show/hide toggle button with jquery but
I'm trying to make a div disappear and reappear after a set amount of
I am trying to make a div slide to a FIXED position on the
I am trying to make my DIV's height expand to it's child elements. I
I'm trying to make a div assume 100% of it's parent div. The parent
I'm trying to make a div with an image in it that I'm using

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.