+ 1

How can I make the body change background image only when the animation above it finishes?

'''document.querySelector("#op").style.animation = "fadeIn 2s"; document.querySelector("body").style.backgroundImage = "url("+ url +")"; document.querySelector("#op").style.animation = "fadeOut 2s";'''

28th Nov 2020, 3:44 AM
Jeremy Cruz
Jeremy Cruz - avatar
1 ответ
+ 4
Set a timeout of 2 seconds: setTimeout ( function (){ }, 2000) Or use animationend event: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/animationend_event
28th Nov 2020, 8:30 AM
Kevin ★