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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:12:47+00:00 2026-05-29T12:12:47+00:00

I am creating a very simple quiz application with jQuery. How it works is

  • 0

I am creating a very simple quiz application with jQuery. How it works is you have a question and three answers. Clicking on the wrong answer makes the clicked answer’s opacity fade to 60%. Clicking on the correct answer should make all the wrong answers fade out completely leaving only the correct answer remaining.

The page has 3 quizzes selectable by a navigation. So I am sorting through tests and questions using .index() to target the specific question at hand. Which works as other elements of the quiz are working fine.

The only issue I am having is getting the other answers to fade out on selecting the correct answer. Right now, only the first question is functioning this way; all other questions remain at 100% opacity. I’ve been staring at it all night trying to get it to go and could use an extra set of eyes on this.

CODE :

 $('#test .test li ol li').click(function() 
{
    if($(this).attr('class') == 'correct')
    {
        var testNum = $(this).closest('.test').index('.test');
        var qustNum = $(this).index('.correct');
        var corAns = $(this);
        var theList = $('.test:eq(' + testNum + ') li:eq(' + qustNum + ') ol li');

        //find other questions
        theList.not('.correct').animate({ opacity : 0 }, 1000);

        getAnswer(testNum, qustNum, corAns);
    }
    else 
    {
        $(this).animate({ opacity : 0.6 }, 500);
    }
});

function getAnswer(testNum, qustNum, corAns)
{
    console.log(testNum + ' : ' + qustNum + ' : ' + corAns.text());

    //get xml file with answers
    $.ajax({
        type: "GET",
        url: "answers.xml",
        dataType: "xml",
        success: function(xml) {
             $(xml).find('Answers').each(function(){
                //find the answer in the xml
                var answer = $(this).find('test:eq(' + testNum + ') answer:eq(' + qustNum + ')').text();
                console.log(answer);
                //place answer inside correct li
                corAns.html(answer);
             });
        }
    });

    //fade in next button
    $('#test span').css({ 'display' : 'block' }).delay(2000).animate({ opacity : 1 }, 1000);

    $('#test span').click(function()
    {   
        $('.test:eq(' + testNum + ')').animate({ top : '-=286px' }, 500);
    });
}

HTML :

 <section class="content" id="test">
            <h1 style="opacity:0;">test</h1>
            <h2 style="opacity:0;">How Much Do You Know?<span>(choose a test)</span></h2>

            <ul class="nav">
                <li>
                    <img src="_images/_test/test1.jpg" />
                </li>
                <li>
                    <img src="_images/_test/test2.jpg" />
                </li>
                <li>
                    <img src="_images/_test/test3.jpg" />
                </li>
            </ul>

            <ol class="test">
                <li>
                    Which blood cells carry oxygen throughout your body?
                    <ol>
                        <li>White Blood Cells</li>
                        <li class="correct">Red Blood Cells</li>
                        <li>Oxygen Cells</li>
                    </ol>
                </li>

                <li>
                    A blood test procedure can be made easier if you&#8230;
                    <ol>
                        <li class="correct">imagine you are in a comfortable place during the test.</li>
                        <li>wear something red.</li>
                        <li>don't sleep for a week before the test.</li>
                    </ol>
                </li>

                <li>
                    <p>Why do you need to have blood tests?</p>
                    <ol>
                        <li>To make sure you have blood</li>
                        <li>Because it's easier than a math test</li>
                        <li class="correct">So the doctor can check your health</li>
                    </ol>
                </li>

                <li>
                    <p>How often do you need to have a blood test?</p>
                    <ol>
                        <li>Once a year</li>
                        <li>Twice a month</li>
                        <li class="correct">It depends on your health</li>
                    </ol>
                </li>

                <li>
                    <p>How long does it take for your body to replace the blood taken from a blood test?</p>
                    <ol>
                        <li>One year</li>
                        <li class="correct">One day</li>
                        <li>One hour</li>
                    </ol>
                </li>
            </ol>

            <ol class="test">
                <li>
                    <p>How much blood is drawn in a typical blood test?</p>
                    <ol>
                        <li>About half a cup</li>
                        <li class="correct">About one teaspoon</li>
                        <li>About 1/2 gallon</li>
                    </ol>
                </li>

                <li>
                    <p>On average, about how much blood does a person have in their body?</p>
                    <ol>
                        <li class="correct">A little more then one gallon</li>
                        <li>1/2 gallon</li>
                        <li>Four gallons</li>
                    </ol>
                </li>

                <li>
                    <p>Which blood cells help your body fight infection?</p>
                    <ol>
                        <li>Army cells</li>
                        <li class="correct">White blood cells</li>
                        <li>Red blood cells</li>
                    </ol>
                </li>

                <li>
                    <p>Which cells help you stop bleeding if get a cut?</p>
                    <ol>
                        <li class="correct">Platelets</li>
                        <li>Red blood cells</li>
                        <li>Plug-up cells</li>
                    </ol>
                </li>

                <li>
                    <p>The area on your skin where blood is drawn must be cleaned because&#8230;</p>
                    <ol>
                        <li>It's always better to look clean</li>
                        <li class="correct">It is important that the blood sample is not infected</li>
                        <li>The test won't hurt as much</li>
                    </ol>
                </li>
            </ol>

            <ol class="test">
                <li>
                    <p>If you have anemia it means your blood has…</p>
                    <ol>
                        <li>too many red blood cells.</li>
                        <li class="correct">too few red blood cells.</li>
                        <li>too many white blood cells.</li>
                    </ol>
                </li>

                <li>
                    <p>About how many blood chemistry tests are preformed in the United States each year?</p>
                    <ol>
                        <li>100,000</li>
                        <li>3 million</li>
                        <li class="correct">6 billion</li>
                    </ol>
                </li>

                <li>
                    <p>Where are blood cells made?</p>
                    <ol>
                        <li>Your heart</li>
                        <li class="correct">Your bone marrow</li>
                        <li>California</li>
                    </ol>
                </li>

                <li>
                    <p>A Complete Blood Count (CBC) is a test in which…</p>
                    <ol>
                        <li class="correct">all of the different cells in your blood are counted.</li>
                        <li>a machine looks at the chemicals in your blood to check for disease.</li>
                        <li>the amount of blood in your body is counted.</li>
                    </ol>
                </li>

                <li>
                    <p>Testing for blood types is important in order to…</p>
                    <ol>
                        <li class="correct">receive the right blood type if you ever need blood.</li>
                        <li>be eligible for a drivers license.</li>
                        <li>learn about your personality.</li>
                    </ol>
                </li>
            </ol>
            <span>Next Question --></span>
        </section>

Additional:
All console.log’s show the correct index is being targeted by the variables on each click.
The test html is built of nested ordered lists.

Thanks for any help on this. I’ll bet its something simple I’ve overlooked.

  • 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-29T12:12:48+00:00Added an answer on May 29, 2026 at 12:12 pm

    Replace:

    theList.not('.correct').animate({ opacity : 0 }, 1000);
    

    With:

    $(this).siblings().animate({ opacity : 0 }, 1000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple Java JTable question. I am creating this class to
I'm creating a very simple django upload application but I want to make it
i'm creating a very simple (hello World quality) web application using spring mvc 3.0.
Original Question: Hello, I am creating very simple hobby project - browser based multiplayer
I am creating a simple aspnetmvc cart application and have defined classes similar to
I'm creating a very simple chat application. It has an ASP.NET web page as
I'm creating a very simple Firebug extension to capture page load data. I have
Very simple question: is there a smart way of creating a subvector from regularly
I have a very simple C++ application. #include <stdio.h> #include <iostream> int main(int argc,
I'm creating a very simple timeshare application using Sinatra and Datamapper. Every user in

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.