Load Events
The load event will fire on any resource (window, document, image, stylesheet, script, video/audio file) that has finished loading -- this also includes any dependent resources.
<!-- HTML -->
<img src="http://example.com/example.jpg width="100" height="100" alt="Example Image" />
// JavaScript
var image = document.querySelector('img');
image.addEventListener('load', function(event) {
image.classList.add('has-loaded');
});
<!-- HTML Output Result -->
<img src="http://example.com/example.jpg" class="has-loaded" width="100" height="100" alt="Example Image" />
Written by Brian
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Events
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#