This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
The play()
method of the Animation
Interface starts or resumes playing of an animation, or begins the animation again if it previously finished.
Syntax
element.play();
Example
The following example uses play()
to toggle from a "before" image to an "after" image. This could be paired with similar code to do the opposite using reverse()
.
afterButton = document.getElementById("after"); afterButton.addEventListener('mousedown', function() { player.play(); });
Specifications
Specification | Status | Comment |
---|---|---|
Web Animations The definition of 'play()' in that specification. |
Working Draft |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 39.0 | (Yes) [1] | ? | ? | ? |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | ? | ? | (Yes)[1] | ? | ? | ? | ? | 39.0 |
[1] Before Firefox 40, this property was implemented on the AnimationPlayer
interface.
See also
AnimationPlayer
for other methods and properties you can use to control web page animation.AnimationPlayer.pause()
to pause an animation.AnimationPlayer.reverse()
to move an animation backward.