is a property of an HTML element that gets or sets the HTML content inside that element.
innerHTML
is a property of an HTML element that gets or sets the text content inside that element, without parsing any HTML tags.
textContent
Changing element content
innerHTML
textContent
Creating Elements
createElement()
appendChild()
insertBefore()
This method creates a new element of the type specified. It is used to create any HTML element (like a <div>, <span>, <p>, etc.) that you want to add to the document.</span>
createElement()
This method adds a node (element) to the end of the list of children of a specified parent node. It is used to insert the newly created element into the DOM.
appendChild()
This method inserts a node before the reference node as a child of a specified parent node. It is used when you need to insert an element at a specific position within a parent node.
insertBefore()
This method removes a specified child node from the DOM and returns it. It is used to remove a specific element from its parent.
removeChild()
This method replaces an existing child node with a new node. It is used to swap one element with another within a parent node.
replaceChild()
Removing Element
removeChild()
replaceChild()
are actions or occurrences that happen in the browser, which the browser can detect.
Events
These can be triggered by user interactions (like clicking a button or pressing a key), by the browser itself (like when a page loads), or by JavaScript (such as triggering an animation)
Events
is the process of detecting and responding to these events in JavaScript.
Event Handling
is a signal that something has happened in the browser, such as a user clicking a button, submitting a form, moving the mouse, or the browser loading a page.
Event
What are the types of events
Mouse Events: click, dblclick, mouseover, mouseout, etc.
Form Events: submit, change, focus, blur.
Window Events: load, resize, scroll, unload.
allows you to add many events to the same element, without overwriting existing events:
addEventListener()
are events that occur on the window object, which represents the browser’s window or tab displaying the web page.
Window events
These events are related to the browser window or document as a whole rather than to specific elements within the page.
Window events