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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:03:11+00:00 2026-05-24T13:03:11+00:00

In an html form I have a checkbox that has a label. When you

  • 0

In an html form I have a checkbox that has a label. When you click the checkbox or its label, it toggles the checkedness of the checkbox. It’s wrapped in a <div>.

I am using jquery to hide another element of the form if the checkbox is checked. Originally I was using the .click() function of the wrapping div. But I noticed that you could click between the checkbox and the label ( which is still within the div), and get the other to hide, even though the checkbox was not checked. (Also, for some reason, clicking on the label caused the element to hide then reappear, but I don’t think I need to open that can of worms).

I was thinking that instead of the click() of the div, I should look at both the checkbox and the div separately. Then I thought I just might look for something like an onChange event for the checkbox itself, which clicking the label should affect. Then I thought that people have probably solved this problem before and I should not try to re-invent the wheel.

What’s a simple way to keep the checkbox value and the hide/show state of my element in sync, when two different elements can change the checkbox status?

  • 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-24T13:03:13+00:00Added an answer on May 24, 2026 at 1:03 pm

    Attach a onclick event to the checkbox (a onchange event works too). Whether you click on the checkbox itself, or its label, the event handler will fire. Just make sure that the label’s for attribute contains the id of the checkbox.

    http://jsfiddle.net/FishBasketGordo/GJbce/

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

Sidebar

Related Questions

I have a basic HTML form that gets inserted into a server side div
I have a html-form with checkboxes. It is required that has been checked by
I have a html page with a form that has some check boxes. I
I have some checkbox that looks like this <%= Html.CheckBox(Remember) %> <%= Html.Label(Remember, Keep
I have the following HTML/JS/jQuery Code. This code represents a login form that is
I have an HTML form: <form action='process.php' method='post'> <input type='checkbox' name='check_box_1' /> Check me!<br>
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
If I have a HTML form with some embedded div s, and after the
I have a HTML form, and I have a Controller Action that accepts the
I have a checkbox list control on my asp.net web form that I am

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.