Element.replaceChildren() — replacing all children
Element.replaceChildren() replaces an element's children with node and string arguments. Calling it without arguments removes all children.
CKTIS / JavaScript
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Element.replaceChildren() replaces an element's children with node and string arguments. Calling it without arguments removes all children.
Element.replaceWith replaces an element within its parent with nodes and text. Strings become text rather than HTML markup.
Element.setAttribute takes a name and a value for an attribute on a DOM element. On success, it adds the attribute or replaces its value.
The setPointerCapture(pointerId) method directs subsequent events for one pointer to a chosen element, even after the pointer leaves its bounds. It supports dragging with a mouse, touch, or pen.
ErrorEvent is a Web API interface describing errors in scripts or files. Its message property provides a textual description, while error holds the associated JavaScript value—not necessarily an Error object.
Event represents an event. Its properties describe the event's type, target, and creation time.
Event.bubbles is a read-only Boolean property indicating whether an event can bubble from its target to its ancestors. A value of false does not disable capturing or handling at the target itself.
Event.currentTarget identifies the object whose listener is currently being invoked. Unlike event.target, it describes where the event is handled, not its target.
preventDefault() marks an event as canceled to prevent its associated default action. It requires cancelable: true and does not work inside a passive listener.
stopPropagation() stops further event propagation without canceling the default action or the remaining listeners in the current invocation.
EventTarget is a Web API interface for registering listeners and dispatching events. A standalone instance can be created without a DOM element.
Event.target identifies an event's target, not necessarily the object handling its listener. Learn how it differs from Event.currentTarget.
EventTarget.addEventListener registers an event callback. The capture, once, and passive options control invocation and whether the listener can cancel the event.
dispatchEvent(event) synchronously dispatches an event to a target. Its Boolean result indicates cancellation, not whether listeners exist.
removeEventListener() removes a listener by matching the event type, callback identity, and capture value on the same target.
fetch() retrieves a resource and returns Promise<Response>. An HTTP error status does not automatically reject the promise; check response.ok.
FocusEvent.relatedTarget identifies the other object involved in a focus transition: the previous target when gaining focus or the next target when losing it. The property is read-only and may be null.
Disabled form controls cannot be operated or focused by the user, and their values are not submitted. In JavaScript, the disabled property switches a control's own disabled state, while a containing fieldset can also disable it.
FormData stores ordered name–value pairs, including repeated names. Learn the difference between append() and set(), how to iterate with entries(), and how to send the data using fetch().
FormData.get(name) reads the first value with the specified name: a string or File. If no entry exists, it returns null rather than an empty string.
GainNode multiplies audio samples by the gain parameter, enabling muting, amplification, and amplitude automation.
HTMLElement.onerror assigns a handler for an element's error event, such as an image loading failure. It is not a global mechanism for catching JavaScript exceptions.
HTMLElement.onload is the event-handler property for load. Assign a function to react to an element's resource loading, such as an image. A subsequent assignment replaces the previous function, while null disables that handler.
Headers stores HTTP headers for Fetch, supporting reading, appending, replacement, deletion, and iteration.