D7 - hide the ajax_command_html message I'm using the following code to display a (success) message, it's working quite nicely, however I want it to disappear after, lets say 3 seconds.

  $commands = array();
  $commands[] = ajax_command_html('.ajax_messages', ' message ');
  $page = array(
  '#type' =&gt; 'ajax',
  '#commands' =&gt; $commands,
  );

  ajax_deliver($page);


How can I achieve this?
Maybe something like this in a js file included on the page.

(function ($) {
  Drupal.behaviors.myModule = {
    attach: function (context, settings) {
      $('.ajax_messages').delay(3000).fadeOut();
    }
  };
})(jQuery);