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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:58:38+00:00 2026-06-15T20:58:38+00:00

In Chrome, this code works just fine. But in Firefox – it does not.

  • 0

In Chrome, this code works just fine. But in Firefox – it does not. I’m stuck…

$(document).ready(function(){

var score = 0;

$('.left').hide();
$('.right').hide();

$("#score h2").html("What emotion is being shown?").hide().fadeIn('slow');

$('.happy').click(function(){

    if($(this).hasClass('happy') && $(".thegame").find("img:eq(1)").hasClass("happy")){
    $('.left').show();
    $('.right').show();
    score++;
    $(numbz).html(score);
            setTimeout(trolli,3000);
    function trolli(){

         sadgame = $('.thegame').html('<div class="pic"><img class="left" src="img/sadness02.jpg"/ ></div><div class="pic"><img class="sadness" src="img/sad03.jpg"/ ></div><div class="pic"><img class="right" src="img/sadness01.jpg"/ ></div>');
        $('.left').hide();
        $('.right').hide();
       $("h2").removeAttr('id', 'canswer').html("What emotion is being shown?").hide().fadeIn('slow')};

        $("h2").attr('id', 'canswer').html("You are correct! Happiness looks the same on everybody!").hide().fadeIn('slow');
    } else if(!$(".thegame").find("img:eq(1)").hasClass("happy")){
        $("#score h2").attr('id', 'wanser').html("You are not correct! Try again.").hide().fadeIn('slow');
        score--;
        $(numbz).html(score);
    };


});

My HTML:

<!DOCTYPE html>
<head>
    <link rel="stylesheet" href="stylesheet.css">
    <title>
        facetest.com
    </title>
</head>

<body>
    <div id="container">
        <div id="answers">
        <div class="sadness">
            <p class="feelings">SADNESS</p>
        </div>
        <div class="anger">
            <p class="feelings">ANGER</p>
        </div>
        <div class="surprise">
            <p class="feelings">SURPRISE</p>
        </div>
        <div class="fear">
            <p class="feelings">FEAR</p>
        </div>
        <div class="disgust">
            <p class="feelings">DISGUST</p>
        </div>
        <div class="contempt">
            <p class="feelings">CONTEMPT</p>
        </div>
        <div class="happy">
            <p class="feelings">HAPPINESS</p>
        </div>

        </div>

        <div class="thegame">
            <div class="pic">
                <img class="left" src="img/happy-man.jpg"/ >
            </div>
            <div class="pic">
                <img class="happy" src="img/happy-woman.jpg"/ >
            </div>
            <div class="pic">
                <img class="right" src="img/happy-celeb.jpg"/ >
            </div>
        </div>

        <div id="score">
            <h2 class="emoz">What emotion is being shown?</h2>
            <h3 class="playmeist">Score: <div id="numbz">0</div> pts.</h3>
            </div>
    </div>
</body>
</html>

Again, this code works just fine in Chrome. But not in Firefox. Why is that?
It just keeps giving me 1 point for clicking happiness every time. But only in Firefox.

  • 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-15T20:58:40+00:00Added an answer on June 15, 2026 at 8:58 pm

    If you launch firebug in Firefox you can see the problem. It isn’t finding your trolli function.

    Try moving that function and your score variable outside the scope of your document.ready call.

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

Sidebar

Related Questions

ok, this code works just fine in Chrome. But, for some reason it does
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr
I have this code running great in ff, opera and chrome: <script type=text/javascript> $(document).ready(function(){
My code works fine in firefox but in Chrome I get an error. It's
Edit: Just found out this is a chrome problem, the code works fine in
Consider this JSFiddle . It works fine in Firefox (14.0.1), but fails in Chrome
This code : http://jsfiddle.net/bYtTG/1/ Works as I want in FF, chrome and opera, but
Here is my code, this does not work in Chrome, Safari, FF or Opera.
This code takes 3 seconds on Chrome and 6s on Firefox. If I write
Trying to create and submit form within a javascript call. This code works fine

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.