I have this code and I want that the alert will pop up only after the backgroundImage is loaded.
$('#element').click(function(){
$('#element').css({
backgroundImage: "url('http://www.button.jpg')",
backgroundRepeat: 'no-repeat',
backgroundPosition: '7px 5px'});;
alert ("button is loaded");
The button.jpg
is a small size: 3 KB.
But when I click on the button element, first the ALERT pop up, and 2 seconds after the image is complete loding.
I read about callBack
Also about Delay()
Also about timeout
But I am new in coding, and didn't understand what and how should I do here.