I am new to JS and hope someone can help me with this.
I am trying to fade out a div, then wait two seconds and then redirect to another page.
So far I have the following which does the redirect as required but I don't think I am using the setTimeout correctly since the redirect always happens immediately independent of the value I set for the timeout.
Can someone tell me how I have to combine this so that JS waits before the redirect ? I would like to use setTimeout
rather than delay etc., if possible.
setTimeout(function(){ $(that).closest('div.boxBlueOuter').fadeOut(), 2000 });
// redirect to index page
window.location.href = baseURL + '/index.php?lang=' + selectedLang;
Many thanks in advance, Mike