First I was looking at the onLoad
event, but then when I read about it, I discovered that I was or going to be deprecated, so I search and found this info to use the on
event to check if an image is loaded:load() method deprecated?
But the simple animation I will trigger, will not work. The element is not visible. It works if I reload the browser. The animation worked perfect until I added the load event. What could be wrong and how can I improve the code to work better?
$("#intro-img").on("load", function() {
$(".intro-content").animate({
left: '20px',
opacity: '1.0'
});
});
EDIT:
The script is running now after I used window
instead of the id. Like this $(window).on("load", function() {....
Now the script should run when all content on the page has been loaded? But I guess there is never a guarantee that it will work 100% with images!?