简体   繁体   中英

How to find if all animations have completed

I am trying to create a jquery login box and I want to show one form, only if all other animations are complete.

I understand I can do multiple .is(':animated') checks, but I was wondering, is there a way to select all animated objects and the check if I have selected exactly zero elements?

if ($(":animated").length === 0) {
   // do something

}

As per Jasper's comment, and what it says in the :animated selector doco , you can improve performance by selecting a container element or otherwise narrowing down the field before using :animated . Eg,

if ($("#container").find(":animated").length === 0) {

// OR

if ($(".someClass").filter(":animated").length === 0) {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM