I have a button with next-step in my funnelish page. When clicked, it opens a “loading” pop up. To give the loading effect, I want there to be a delay between when the button is pressed and when it actually changes URL and goes to the next step. I tried many different versions of the code but none work.
Create a popup that displays a loading effect. Below the loading effect, add a button with the id next-step-btn, and make the button initially invisible. After the loading effect is complete, reveal the button and set it to proceed to the next step.
const btn = document.querySelector("#next-step-btn");
const buynow = document.querySelector("#buy-now");
buynow.addEventListener("click",()=> {
console.log("click");
// This function will be executed after 2000 milliseconds (5 seconds)
setTimeout(function() {
btn.click();
}, 5000); // you can set the delay time from here 5000
})