In the example below I want to pause the script after changing the style of element one. Then after 500 miliseconds, proceed to change the style of element two. As setTimeout()
requires a function parameter, how do I achieve this without delaying the entire function?
Note: the function is called by onclick="myFunction()"
on an HTML element.
function myFunction() {
// Declare some variables
var elementOne = document.getElementById("classElementOne");
var elementTwo = document.getElementById("classElementTwo");
// Execute for element 1
elementOne.style.cssText = "some styles";
// Wait 500 miliseconds
// Execute for element 2
elementTwo.style.cssText = "some styles";
}