DOM - Ready event (Readiness|readyState)
Table of Contents
1 - About
A page in a ready state, all images are not finished downloading, including banner ads.
2 - Articles Related
3 - State
The readyNess can be read in the readyState property of the document
document.readyState
complete
The document.readyState property returns:
- loading while the Document is loading, (ie if the document is associated with an HTML parser, an XML parser, or an XSLT processor)
- interactive once it is finished parsing but still loading sub-resources,
- and complete once it has loaded.
The readystatechange event fires on the Document object when this value changes.
4 - Run code at event
4.1 - DOM
window.addEventListener('DOMContentLoaded', function () {
console.log("It's ready!")
})
4.2 - Jquery
To run code as soon as the document is ready to be manipulated in Javascript - JQuery with the Ready event
$( document ).ready(function() {
// Your code here.
});