js dom ready code example
Example 1: dom ready js
document.addEventListener("DOMContentLoaded", function() {
// code
});
Example 2: document. ready
$( document ).ready(function() {
console.log( "ready!" );
});
Example 3: dom is loaded
document.addEventListener('DOMContentLoaded', (event) => {
console.log('DOM fully loaded and parsed');
});
Example 4: wait for the dom to load javascript
document.addEventListener('DOMContentLoaded', (event) => {
//the event occurred
})