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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:25:35+00:00 2026-05-31T19:25:35+00:00

<div class=accordion-group> <div class=accordion-heading> <a href=#collapse data-parent=#accordionQuiz data-toggle=collapse1.. class=accordion-toggle> <strong>1…</strong> Question </a> </div> <div

  • 0
<div class="accordion-group">
    <div class="accordion-heading">
        <a href="#collapse" data-parent="#accordionQuiz" data-toggle="collapse1.." class="accordion-toggle">
        <strong>1...</strong>
        Question
        </a>
    </div>

    <div class="accordion-body collapse" id="collapse1..">
        <div class="accordion-inner">
            <div class="control-group">
                <label for="1..@1.." class="control-label">A..</label>
                <div class="controls">
                    <label class="checkbox">
                    <input type="checkbox" value="FirstAnswer" name="1..@1.." id="1..@1..">
                    content
                    </label>
                </div><!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="control-group">
                <label for="2..@2.." class="control-label">B..</label>
                <div class="controls">
                    <label class="checkbox">
                    <input type="checkbox" value="SecondAnswer" name="2..@2.." id="2..@2..">
                    content
                    </label>
                </div><!-- /.controls -->
            </div><!-- /.control-group -->

        </div><!-- /.accordion-inner -->
    </div><!-- /.accordion-body collapse .. -->
</div><!-- /.accordion-group -->

Above code is a piece of Quiz form and is repeating for every question. It looks like: Example


How to catch the event when none of question-related-checkboxes is checked or at least one is checked and then add a class for the div.accordion-heading?

Something like: none is checked – empty, at least one – not-empty.

There’ll be diferent colours and it’ll be very useful feature for user to come back to the question which he skiped becouse only one is visible at a time.

I tried do this by myself but I’ve just started to learn jQuery and… I give up. Perhaps this is a job for mighty AJAX?

  • 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-31T19:25:36+00:00Added an answer on May 31, 2026 at 7:25 pm

    It is pretty simple to accomplish this with the following steps:

    1. Register an event for click on all checkbox.
    2. On each click count how many checkbox were checked in group.
    3. Then take an action base on the number of checked checkboxes.

    The JavaScript code looks like this, which can be optimized.

    $('.accordion-group :checkbox').click(function() {
        var $this = $(this);
        var $group = $this.parents('.accordion-group:first');
        var $checkboxes = $group.find(':checkbox');
        var checks = 0;
        $checkboxes.each(function() {
            if ($(this).is(':checked')) {
                checks++;
            }
        });
        console.log(checks);
    
        var $heading = $group.find('.accordion-heading');
    
        if (checks === 0)
            $heading.removeClass('not-empty').addClass('empty');
        else
            $heading.removeClass('empty').addClass('not-empty');
    });​
    

    I made a demo at jsfiddle: http://jsfiddle.net/W2XD2/


    EDITS

    I optimized the script to be more specific, and optimize it:

    $('.accordion-group :checkbox').click(function() {
        var $group = $(this).parents('.accordion-group:first');
        var checks = $group.find(':checked').length;    
        var $heading = $group.find('.accordion-heading');
    
        if (checks === 0)
            $heading.removeClass('not-empty').addClass('empty');
        else
            $heading.removeClass('empty').addClass('not-empty');
    });​
    

    You can check the updated revision at jsfiddle: http://jsfiddle.net/W2XD2/1/

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

Sidebar

Related Questions

How can I achieve this with jQuery? If <a href=# class=accordion-link> is clicked, add
How to apply jquery accordion function to a div with a particular class... i.e.
I have the following HTML: <div class=accordion> <h3>My title</h3> <div>My content</div> <h3>My title</h3> <div>My
I'm trying to make a simple accordion style menu using divs: <div class=subdomainLevel> Subdomain
I'm developing a html with this structure div id=menuContainer> <div class = menu ui-accordion-header
<div class=accordion> <ul class=navigation> <li>Lorem</li> <li>Ipsum</li> <li>Donor</li> </ul> <ul class=navigation> <li>Test</li> <li>Demo</li> <li>Donor</li> </ul>
<div class=accordion> <ul class=navigation> <li>Lorem</li> <li>Ipsum</li> <li>Donor</li> </ul> <ul class=navigation> <li>Test</li> <li>Demo</li> <li>Donor</li> </ul>
I want to scale the picture to fit the main div class http://jsfiddle.net/EyW99/ Sorry,
<div class = a> <div class = a b> text </div> </div> <script> alert($(.a).html());
How can I get an image to stretch the height of a DIV class?

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.