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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:15:09+00:00 2026-06-15T13:15:09+00:00

I have two checkboxes called open_sub_ja and open_sub_nee. Only one of them can be

  • 0

I have two checkboxes called “open_sub_ja” and “open_sub_nee”. Only one of them can be checked. Now the thing I’m trying to do is that when the checkbox with the class “open_sub_nee” is checked I want a different div to add a class and when the checkbox “open_sub_nee” looses the checked state I want the other div to remove that class (so a toggle).

I’ve googled and found something that comes really close to what I want to do (after a b it of modification). This code does add the class “selected” to the right div when the “open_sub_nee” is checked but it does not toggle when the checkbox does not have the checked state.

$('.open_sub_nee').change(function() {
        if($(this).is(':checked')) 
            $(this).parents('.container_vragen').find('.akkoord').addClass('selected'); 
        else
            $(this).parents('.container_vragen').find('.akkoord').removeClass('selected');
    });

I’ve got a jsFiddle of the project here: http://jsfiddle.net/R5cWW/ allthough the project is getting a bit bigger and my coding isn’t the best.

  • 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-15T13:15:10+00:00Added an answer on June 15, 2026 at 1:15 pm

    Why could use a radio button instead?

    I’m not entirely sure I understand your question. You want to add a class to the unchecked checkbox’s parent div-tag, correct?

    $('.open_sub_nee').change(function() {
        if($(this).is(':checked')) {
            $('.open_sub_ja').attr('checked', '').closest('div').addClass('someclass');
        } else {
            $('.open_sub_ja').closest('div').removeClass('someclass');
        }
    });
    

    Then do the same for “.open_sub_ja”.

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

Sidebar

Related Questions

I have two checkboxes. I need to check that at least one of them
I've been trying to make it impossible to have two checkboxes checked at the
I have two checkboxes. each one have a sub form that is disable when
I have a GridView gvpodetails. In that I have two checkboxes one in the
Here is my code, I have two checkboxes and want to keep one disabled
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two tabs one called Sale-Items and the other All-Items and for each
I'm creating a form that has two checkboxes yes and no. I have added
Lets say I have a simple table that only contains two columns: MailingListUser -
I have two checkboxes name check1 and check2. I wanted for either one to

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.