how to check if dom is loaded in js code example
Example 1: dom is loaded
document.addEventListener('DOMContentLoaded', (event) => {
console.log('DOM fully loaded and parsed');
});
Example 2: how to check if page is loaded in javascript
<body onload="onload()">
<div>
<p>TEXT</p>
</div>
</body>
<script>
function onload(){
console.log("Window Has Been Loaded!")
}
</script>