JavaScript – DOM Element closest() Method
The Element closest() method searches up the DOM tree (the element and then its ancestors) for elements which matches a specified CSS selector.
The Element closest() method searches up the DOM tree (the element and then its ancestors) for elements which matches a specified CSS selector.
The Element compareDocumentPosition() method compares two nodes, and returns an integer describing where they are positioned in the document.
The Element contains() method returns “true” if a node is a descendant of a node, and returns “false” if it’s not.
The Element focus() method gives focus to an element if it can receive focus.
The Element getAttribute() method returns the value of an element’s attribute.
The Element getAttributeNode() method returns an element’s attribute.
The Element getBoundingClientRect() method returns the size of an element, and its position relative to the viewport.
The Element getElementsByClassName() method returns a collection of child elements with a given class name.
The Element getElementsByClassName() method returns a collection of child elements with a given tag name.
The Element hasAttribute() method returns “true” if the attribute exists, and “false” if it does not exist.
The Element hasAttributes() method returns “true” if a node has attributes, and “false” if it does not.
The Element hasChildNodes() method returns “true” if the specified node has any child nodes, and “false” if it does not have any child nodes.
The Element insertAdjacentElement() method inserts an element into a specified position.
The Element insertAdjacentHTML() method inserts HTML code into a specified position.
The Element insertAdjacentText() method inserts text into a specified position.
The Element insertBefore() method inserts a child node before an existing child node.
The Element isDefaultNamespace() method returns “true” if the elements’s namespace is default, and “false” if it is not.
The Element isEqualNode() returns true if two elements are equal.
The Element isSameNode() method checks if two nodes are the same node, returning “true” if the two nodes are the same node, and “false” if not.
The Element matches() method returns true if an element matches a specific CSS selector or selectors.