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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:57:40+00:00 2026-05-25T16:57:40+00:00

I have been playing with a simple function which basically flashes an element with

  • 0

I have been playing with a simple function which basically flashes an element with a background color, then fades out. It works quite well:

$.fn.animateHighlight = function(highlightColor, duration) {
  var highlightBg = highlightColor || "#FFFF9C";
  var animateMs = duration || 1500;
  var originalBg = this.css("backgroundColor");
  this.stop().css("background-color", highlightBg).animate({backgroundColor: originalBg}, animateMs);
};

It is then called via:

$('input.flasher').animateHighlight('#e9fff5',1000);

The problem is however is when I’ve tried to use this on an element that doesn’t have a css background-color – ie its background-color: transparent

How does one go about fading a backgroundColor to transparent? Or at least creating the illusion that is what happens?

I changed the function to include an additional attribute ‘originalColor’

$.fn.animateHighlight = function(highlightColor, originalColor, duration) {
  var highlightBg = highlightColor || "#FFFF9C";
  var animateMs = duration || 1500;
  var originalBg = originalColor || "#ffffff";
  this.stop().css("background-color", highlightBg).animate({backgroundColor: originalBg}, animateMs);
};

This works ok, but then my field is left with the originalColor written in its style, when the end result needs to be an input that has a transparent background color.

I’m guessing I could add some extra functionality which removes backgroundColor at the end of the animation, but wondering how you would go about achieving this, or a better approach.

  • 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-25T16:57:41+00:00Added an answer on May 25, 2026 at 4:57 pm

    Adding a removal of the background color after the animation:

    $.fn.animateHighlight = function(highlightColor, originalColor, duration) {
        var $this = $(this),
            highlightBg = highlightColor || "#FFFF9C",
            animateMs = duration || 1500,
            originalBg = originalColor || "#ffffff";
    
        this.stop().css("background-color", highlightBg).animate({backgroundColor: originalBg}, animateMs,
    
        function(){
    
            $this.css('background-color', '');
    
        });
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been playing around a bit with a fairly simple, home-made search engine,
I have been playing with the Ruby library shoes. Basically you can write a
I've been playing with JQuery UI draggable and have been struggling with maintaining element
I have been playing around with writing some simple card games in Python for
I have been playing around with node.js, and coming from a Java background, I
I have been playing with the idea of using a simple screen-scraper using jQuery
I have been playing with this for a while, but the closest I have
I have been playing with the Linq to Sql and I was wondering if
I have been playing around with the postgresql.conf file for a couple days now.
I have been playing with javascript arrays and I have run into, what I

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.