Callback to .delay()

前端 未结 3 1609
-上瘾入骨i
-上瘾入骨i 2020-12-05 23:43

I have an $image that I .fadeIn and .fadeOut, and then .remove after .fadeOut completes. This is my code:

3条回答
  •  囚心锁ツ
    2020-12-06 00:12

    To my knowledge, you can just strap the calls on after the delay call, like this:

    $image
       .fadeIn()
       .fadeOut()
       .delay(1000)
       .remove()
    });
    

    Such as in the following example from the documentation:

    $('#foo').slideUp(300).delay(800).fadeIn(400);
    

    The temperament of queued items execution spelled out there also:

    ...the .delay() method allows us to delay the execution of functions that follow it in the queue. It can be used with the standard effects queue or with a custom queue. Only subsequent events in a queue are delayed; for example this will not delay the no-arguments forms of .show() or .hide() which do not use the effects queue.

    Read the documentation for further information regarding which queue you're delaying, if you have troubles with the default fx queue you might need to specify one.

提交回复
热议问题