delay JQuery effects

前端 未结 6 1664
别那么骄傲
别那么骄傲 2020-11-27 16:07

I want to fade out an element and all its child elements after a delay of a few seconds. but I haven\'t found a way to specify that an effect should start after a specified

6条回答
  •  情深已故
    2020-11-27 16:42

    You can avoid using setTimeout by using the fadeTo() method, and setting a 5 second delay on that.

    $("#hideAfterFiveSeconds").click(function(){
      $(this).fadeTo(5000,1,function(){
        $(this).fadeOut("slow");
      });
    });
    

提交回复
热议问题