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

  • Home
  • SEARCH
  • 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 6955771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:46:53+00:00 2026-05-27T14:46:53+00:00

Here is code in jsfiddle ! Here is the actual site ! Problem 1:

  • 0

Here is code in jsfiddle !

Here is the actual site !

Problem 1: It seem’s that when I call functions when clicking enter they don’t execute on after each other , it sometimes works if it goe’s in parallel and does everything at once! But this isn’t the actual problem, it’s something I would love some advice!

Problem Actual: When I call enter I switch all the clases and then do a parallel animation on div.third(making background green or red and then fading out), problem is, when I do fast enough it doesn’t resize div.fourth untill background animation finished. So I thought solution for this would be a parallel animation witch doesn’t interact with main animation thus switchClases().

Code where all the magic happens:

// Do everytime we press a key
$(document).keydown(function(){
    // By presing 'Enter' we call exec.
    $("#wraper input.third").bind('keydown',function(e){
        // Make key variable by phrasing the event
        var keyPresed = (e.keyCode ? e.keyCode : e.which);
        // Allow only backspace, delete  and enter
        if (keyPresed == 46 || keyPresed == 8 || keyPresed == 13){
            // If this is true animation is still in progress
            if (transAct) {
                // OBLIVION
                } 
            // Or else start another animation and execution
            else{
            // If 'enter' is pressed then and new row and execute everything
            if((keyPresed == 13) && $("input.third").val()){
                    //Set the new uniqueId
                    uniqueId++;
                    $("div.second").addClass("class"+uniqueId);
                    //Get result number because it will not be his name anymore
                    result = $("input.third").val();
                    //Switch clases
                    SwitchClases(_this);
                    transAct = true;
                    // Her we actualy insert the new line
                    $("<div class='first'>9 x 8 = <input class='first' type='text' disabled='true' maxlength='2'/></div>").css("opacity", "0").hide().prependTo(_this).slideDown().animate({opacity: 0.1},function(){
                            transAct = false;
                        })
                    $("div.third").append(" "+result) // Write down inputed result
                    $("input.third").fadeOut().remove() // Drop input box into black hole
                    $("div.fifth").fadeOut().remove(); // Do same thing to last division

                // Check if answer was correct!
                // Here are two examples with whom you can play as much as you like
                //$(".leftSide div.class"+(uniqueId-1)).stop().animate({backgroundColor: '#00DD00'},100).animate({backgroundColor: 'white'},900);
                // $(".leftSide").stop().animate({backgroundColor: '#DD0000'},100).animate({backgroundColor: 'white'},900);

                //Now set focus to next input area , so we can continue and be lazy by not clicking on new input box!
                $('.newEleCont input.second').focus();
                }
            }
        }
        // Restrict inputing any other character besides a number
        else {
            // Ensure that it is a number and stop the keypress
            if ((keyPresed < 48 || keyPresed > 57) && (keyPresed < 96 || keyPresed > 105 )) {
                e.preventDefault(); 
            }   
        }
    });
});

1) How could I find solution for double animation?
2) How could I improve this code?(that is , using less jquery)

EDIT: As you can see I added additional uniqueID class to every new div.third. And what I want to do is to cast backgroundColor animation only on given uniqueID BUT not interacing with basic third>fourth>fifth class animations, like if they did there own separate things!

  • 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-27T14:46:53+00:00Added an answer on May 27, 2026 at 2:46 pm

    Parallel Animation in jQuery : You can do parallel animation by passing the properties object to animate function. For example:

    var animateProperties = {
    
        top:50px,
        left:100px,
        width:300px,
    
    }
    
    object.animate(animateProperties);
    

    and you can use stop function to stop the animation in progress. I have modified your code, the code that calls animate function is given below.

    var style = {
    
        "opacity": opacity,
        "font-size": fontSize + "px"
    
    }
    
    
    if(animate){
    
           if(index == config.activeIndex + 1){
            style.backgroundColor = '#00EE00';
            $(row).stop(true, true).animate(style, 100)
                    .animate({backgroundColor: 'white'}, 1200);
           }else{
            $(row).stop(true, true).animate(style, 100);
           }
    
    }else{
        $(row).css(style);
    }
    

    You can find the final version of code here http://jsfiddle.net/diode/rBqVE/6/

    I have made this configurable using a config object. You can find it in the code, but to get the best result you will have to modify css also.

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

Sidebar

Related Questions

enter code here Hi All, I have a simple windows service application that connects
Here is code from MSDN . I don't understand why the work isn't just
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
enter code here I have a table on SQL server 2005 with bigint primary
I am writing some jQuery code that involves jumping from several functions. In one
I've looked at a number of different answers here, and they all seem to
here is the code : http://jsfiddle.net/yuliantoadi/hMr7h/ if you try to hover the 'test 2'
Here is sample code: http://jsfiddle.net/BSjGX/1/ <input id=testing /> $('#testing') .keydown(function(e){ if(e.keyCode==13) {return false;} })
I found this count down timer code here http://jsfiddle.net/QH6X8/ I would like to make
I am trying to position few elements correctly, here is my code: http://jsfiddle.net/Tjz6D/ Now

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.