title: How to highlight some elements in a "rotating" fashion?
body: <p>Here's my problem: when the user clicks on the "validate" button, I send an AJAX request that returns an array of "problematic" elements. From that array, I compute the id of the elements I want to highlight then I "flash" them.</p>
  
  <p>This is nice, it works, but they <strong>all flash together</strong>.</p>
  
  <p>I want to flash them one after the other, so that it's longer and looks nicer (= not aggressive). I've spent some time trying to use <code>queue()</code> function (I guess it's the way to go) but didn't manage to make it work.</p>
  
  <p>Any idea how to do this?</p>
  
  <pre><code>/* this is the function to retrieve bg color (= not the actual subject) */
  jQuery.fn.getBg = function() {
      return $(this).parents().filter(function() {
          var color = $(this).css('background-color');
          return color != 'transparent' &amp;&amp; color != 'rgba(0, 0, 0, 0)';
      }).eq(0).css('background-color');
  };
  
  /* this is my flash function (= not the actual subject) */
  function flash(id, font_color, bg_color, nb) {
      var bc=$(id).getBg();
      var cl=$(id).css('color');
      var mx=parseInt(nb);
      if (mx&lt;=0) {
          mx=1;
      }
      for (var i=0; i&lt;mx; i++) {
          $(id).animate({
              backgroundColor: bg_color,
              color: font_color
          }, 200)
          .animate({
              backgroundColor: bc,
              color: cl
          });
      };
  }
  
  function localOnAjaxError(dataMessage)
  {
    var msg='';
    $('#wait').hide('slow');
    /* show the form again and highlight errors */
    $('#s-inscrire-form').show('slow', function() {
      if (msg!='') {
        $('#erreur').fadeIn('slow');
        flash('#erreur', "#f9e4c9", "#aa0000", 3);
      }
      if (dataMessage instanceof Array) {
        for (key in dataMessage) {
          var m=dataMessage[key];
          if(m.indexOf('#error')==0) {
            /* show the id... */
            $(m).fadeIn('slow', function() {
              /* ...then flash the corresponding label */
              flash('#label-'+this.id.substr(7), "#ffffff", "#aa0000", 3);
            });
          }
        }
      }
    });
    seConnecterAssigneClicksConnexion();
  }
  </code></pre>