wait() or sleep() function in jquery?

前端 未结 7 715
醉酒成梦
醉酒成梦 2020-12-04 20:48

I want to add a class, wait 2 seconds and add another class.

.addClass(\"load\").wait(2sec).addClass(\"done\");

Is there any way?

7条回答
  •  渐次进展
    2020-12-04 21:22

    That'd be .delay().

    http://api.jquery.com/delay/

    If you are doing AJAX stuff tho, you really shouldn't just auto write "done" you should really wait for a response and see if it's actually done.

提交回复
热议问题