Search code examples
jqueryfadeout

jquery fadeOut complete got error: fadeOut(...).complete is not a function


I am trying this:

var notifications = $( "#notifications" );
  notifications.fadeOut("slow")
  .complete(function () {
      alert('completed');
  });

But I got: Uncaught TypeError: notifications.fadeOut(...).complete is not a function

Reference: http://api.jquery.com/fadeout/


Solution

  • There is two way to specify on-complete-callback:

    By second parameter:

    var notifications = $( "#notifications" );
    notifications.fadeOut("slow", function () {
        alert('completed');
    });
    

    or by options:

    var notifications = $( "#notifications" );
    notifications.fadeOut({
        duration: "slow",
        complete: function () {
          alert('completed');
        }
    });