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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:48:51+00:00 2026-06-17T16:48:51+00:00

I am just learning JQUERY and I have been playing around with delay() I

  • 0

I am just learning JQUERY and I have been playing around with delay() I wrote a fiddle to show you… What I am trying to do is when a button is clicked, change the background-color of the div and then after a few moments switch the background color again. But when I try it, it just switches to the second color and skips the first.

HTML:

<div class = "animation">


</div> 

<button id = "change"> Click </button>

Here is the Jquery code:

$(document).ready(function(){
$("#change").click(function(){

    $(".animation").css("background", "blue").delay(700).css("background", "red");


    });
});

Here is the link:

JSFiddle

  • 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-17T16:48:51+00:00Added an answer on June 17, 2026 at 4:48 pm

    delay only works for items in the queue (such as animations).

    For anything else, use a regular old timer:

    $("#change").click(function() {
        var $el = $(".animation");
    
        $el.css("background", "blue");
    
        setTimeout(function () {
            $el.css("background", "red");
        }, 700);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning Jquery and am new to writing javascript (I am
I am just learning Jquery templates and trying different things step by step. Now
so I have this jQuery script below that works. But since I'm just learning
I'm just learning jQuery, figuring out what's possible, finding my way around. I'd like
Ok, I'm new to jquery and just learning. I have a bunch of div's
I'm just learning jQuery, I'm so noob. see, we have 2 divs as follows:
I have a very simple question, I am just learning jQuery plugins and saw
I have just started learning Rails and I'm trying to build a post/like type
Just started learning Jquery - here's my problem: I have six divs on a
Gidday Just learning the jquery UI, and have made some really good progress today,

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.