dom loaded event 1

dom loaded event

window.addEventListener('DOMContentLoaded', (event) => {
    console.log('DOM fully loaded and parsed');
});

Here is what the above code is Doing:
1. We’re using the addEventListener() method to attach an event handler to the document.
2. The event handler is a function that will be executed when the event fires.
3. The event handler is passed an event object, which contains information about the event.
4. The event object has a target property, which refers to the element that triggered the event.
5. We’re using the target property to get the value of the element that triggered the event.
6. We’re using the innerHTML property to set the text of the element with the id of demo to the value of the element that triggered the event.

Similar Posts