📅  最后修改于: 2023-12-03 15:00:31.274000             🧑  作者: Mango
Document.getAnimation
is a method in Javascript which is used to get the animation object of the current document, if the document contains one.
document.getAnimations();
This method will return an array of Animation
objects (if there are any) that are associated with the document. If there are no animations present in the document, then it will return an empty array.
const animations = document.getAnimations();
if (animations.length > 0) {
for (let i = 0; i < animations.length; i++) {
console.log(animations[i].id);
}
} else {
console.log("No animations found in the document");
}
This code snippet gets an array of all the Animation
objects present in the document and then logs their id
property to the console. If there are no animations present in the document, then it logs the message "No animations found in the document".
Document.getAnimations
is a simple but useful method in Javascript that allows you to get all the animations present in the document. It returns an array of Animation
objects that you can then use to manipulate or delete the animations in your code.