This setTimeout works perfectly in Firefox, but in Chrome nothing in function timeoutTrigger ever happens, including the alert. Any ideas?
var $this = $('.active-more');
function timeoutTrigger() {
$this.closest(".container").nextAll(".container:first").find(".description:first").removeClass('hide');
$this.closest(".container").nextAll(".container:first").find(".back:first").find("img.portfolio").remove();
alert("is this thing on?");
}
setTimeout(function(){timeoutTrigger()},400)
Google ChromeIn the "Settings" section click on the "Show advanced settings..." Under the the "Privacy" click on the "Content settings...". When the dialog window opens, look for the "JavaScript" section and select "Allow all sites to run JavaScript (recommended)". Click on the "OK" button to close it.
Explanation: setTimeout() is non-blocking which means it will run when the statements outside of it have executed and then after one second it will execute. All other statements that are not part of setTimeout() are blocking which means no other statement will execute before the current statement finishes.
You can also prevent the setTimeout() method from executing the function by using the clearTimeout() method. If you have multiple setTimeout() methods, then you need to save the IDs returned by each method call and then call clearTimeout() method as many times as needed to clear them all.
Switch your setTimeout
statement to the following: setTimeout(timeoutTrigger,400);
The one you wrote is for when the function you're calling has a parameter. Also, you're missing a semicolon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With