jquery Replay CSS Animation problem Resolution _jquery

Source: Internet
Author: User
Recently in the CSS animation, encountered the need to use a script to replay the animation. For example:

CSS Animation code
Copy Code code as follows:

. seed_txt_out. seed_txt H2 {
ANIMATION-NAME:SEED-H2;
Animation-duration:2s;
Animation-timing-function:ease;
animation-delay:0s;
Animation-iteration-count:1;
Animation-direction:alternate;
animation-play-state:running;
position:relative;
top:10px;
}
@keyframes SEED-H2
{
From {top: -120px;}
to {top:10px;}
}

jquery Call Playback
Copy Code code as follows:

$ (". Seed_txt_out"). Children ("div"). Removeclass ("Seed_txt");
$ (". Seed_txt_out"). Children ("div"). addclass ("Seed_txt");

At this point, you will find that the first display, the animation will play correctly, but the second time, the animation will not play.

Later on the Internet to check, the solution is very simple, copy an element, the original remove, in the new above add the style can be.
Copy Code code as follows:

$ (opts.txt). Children ("div"). Removeclass ("Seed_txt");
Temp = $ (opts.txt). Children ("Div:eq" ("+ $"). Parent ("UL"). Children ("Li"). Index (this) + ")";
Newdiv = Temp.clone (true);
Temp.after (NEWDIV);
Temp.remove ();
Newdiv.addclass ("Seed_txt");

Here is a link, foreigners to solve the solution. and said other things. Friends who encounter similar problems can be consulted, of course, in English.
http://css-tricks.com/restart-css-animation/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.