Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Knowledge base — JavaScript

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 1003

JavaScript

DragEvent.dataTransfer — drag data

DragEvent.dataTransfer exposes the DataTransfer object for a drag event. Access to its payload depends on the operation's phase; a script-created event can return null.

Intermediate · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element — DOM structure, geometry, and scrolling

Element represents a DOM element, not an arbitrary node. It provides navigation, attributes, and content replacement; browsers also expose layout measurements and scrolling. Distinguish tree structure, client-area dimensions, and viewport-relative rectangles.

Intermediate · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.after() — inserting siblings after an element

Element.after inserts nodes and text as siblings, normally immediately after the element. It does not add children to that element.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.animate — keyframes and animation timing

Create animations with Element.animate by defining keyframes and timing options, then control the returned Animation object.

Intermediate · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.append — appending nodes and text

`Element.append` adds nodes and text at the end of an element and returns `undefined`. If `a` and `b` are distinct elements, a successful call to `element.append(a, b, a)` leaves `b` followed by `a` at the end: the last occurrence of `a` moves the node rather than copying it. If instead `a` is a `DocumentFragment` containing one text node and `b` is a separate element, the first occurrence of `a` places the text node before `b` and empties the fragment. The last occurrence adds nothing, and the fragment itself is never inserted.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.attachShadow — attaching a Shadow DOM tree

Element.attachShadow() attaches a Shadow DOM root to a supported element and returns a ShadowRoot. The required open or closed mode controls access through host.shadowRoot, not a security boundary.

Intermediate · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.before() — inserting before an element

Element.before() inserts nodes and text into the element’s parent, not into the element itself. They normally go before the reference element.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.classList — managing an element’s classes

Element.classList provides a live DOMTokenList for reading and changing individual classes without replacing the entire class attribute.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.className — reading and replacing classes

On an HTML element, use `className` to read or replace the `class` attribute value as a string, not an array of classes. `SVGElement.className` is read-only and returns an `SVGAnimatedString`.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.closest — nearest matching ancestor

Element.closest(selectors) checks the element and then its ancestors. It returns the first element matching the CSS selector, or null.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.getAttribute — reading an attribute value

Element.getAttribute reads a DOM element's attribute as a string, or returns null when that attribute does not exist.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.getBoundingClientRect(): an element’s bounding rectangle

Element.getBoundingClientRect() returns a DOMRect describing an element’s viewport-relative position and size. The measurement includes padding, borders, and CSS transforms; the result is a snapshot.

Intermediate · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.id — element identifier

Element.id reads and changes a DOM element’s id attribute. A missing attribute produces an empty string.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.innerHTML — read and replace HTML contents

Element.innerHTML reads an element’s contents as HTML markup or replaces them with nodes parsed from supplied markup. It does not sanitize untrusted data and can introduce XSS.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.lastElementChild — the last element child

Element.lastElementChild returns the last direct child that is an element, or null. It skips text and comments.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.matches — testing a CSS selector

Element.matches tests whether a particular element matches a CSS selector. It returns a boolean, not an element; invalid selector syntax causes an exception.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.nextElementSibling — the next sibling element

Element.nextElementSibling returns the nearest following element with the same parent, or null. It skips text nodes and comments.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.prepend — inserting at the start of an element

Element.prepend inserts nodes and text before an element’s first child. If a and b are distinct elements, prepend(a, b, a) inserts b followed by a, without duplicating a.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.previousElementSibling — previous sibling element

The previousElementSibling property returns the nearest earlier element with the same parent, or null, skipping text and comments.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.querySelector — first matching descendant

Element.querySelector finds the first descendant matching a CSS selector. It returns an element or null; an invalid selector causes an exception.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.querySelectorAll — finding descendant elements

Element.querySelectorAll returns a static NodeList of descendants matching a CSS selector. Later tree changes do not update the list.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.releasePointerCapture() — releasing pointer capture

releasePointerCapture(pointerId) releases an element's capture of a particular pointer, restoring normal position-based event targeting.

Intermediate · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.remove(): detaching an element

The element.remove() method detaches an element from its parent. It takes no arguments, returns undefined, and does nothing when the element has no parent.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Element.removeAttribute — removing an attribute

Element.removeAttribute removes an element's attribute by name. It returns undefined; a missing attribute does not cause an error.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support