I am working on a website.
At some point, I need to replace the background-image of a div with a photo. However, this takes about 5 seconds, so I want to show and hide a loading screen while this process gets completed. I tried:
function changeBackgroundImage(imageURL) {
showLoadingScreen();
$("#imagePlaceholder").css('background-image', imageURL);
hideLoadingScreen();
}
But hideLoadingScreen() is executed before the jQuery css happens.
I'd like to add hideLoadingScreen() as a callback of jQuery css instead. Is this possible?
Here are my other 2 functions:
function showLoadingScreen(){
$('#pleaseWait').removeClass('hidden');
console.log('show loading');
}
function hideLoadingScreen(){
$('#pleaseWait').addClass('hidden');
console.log('hide loading');
}
.css()does not.