1

I have the below javascript function that flashes the bg of a link 3 times when a new document is added to a list.

This works fine the first time, but subsequent calls to the function cause the flashing to become messed up. The more it's called the weirder the flashing behaviour becomes.

I am seeing the same effect in IE8 and the latest version of Chrome.

var highlightNew = function (control) {
    var item = $('li.new-document a.document-link', control);
    if (item.length > 0) {
        var highlightColor = '#ffa500';
        item.stop()
            .animate({ backgroundColor: highlightColor }, 'slow')
            .animate({ backgroundColor: 'transparent' }, 'slow')
            .animate({ backgroundColor: highlightColor }, 'slow')
            .animate({ backgroundColor: 'transparent' }, 'slow')
            .animate({ backgroundColor: highlightColor }, 'slow')
            .animate({ backgroundColor: 'transparent' }, 'slow');
    }
}
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
raydenl
  • 397
  • 1
  • 4
  • 16

1 Answers1

0

Do you have a plugin for this?

You cannot animate background color, per jQuery documentation. jQuery recommends the jQuery.Color plugin to be used for this.

jQuery animate documentation - http://api.jquery.com/animate/

jQuery color plugin - https://github.com/jquery/jquery-color

JSess
  • 638
  • 4
  • 13