JavaScript – HTML DOM methods

Below is the  table of commonly used JavaScript HTML DOM methods:

getElementByIdReturns the element that has the ID attribute with the specified value
getElementsByTagNameReturns a list of elements with the specified tag name
getElementsByClassNameReturns a list of elements with the specified class name
querySelectorReturns the first element that matches a specified CSS selector(s)
querySelectorAllReturns a list of elements that match a specified CSS selector(s)
createElementCreates an HTML element
createTextNodeCreates a text node
appendChildAdds a new child node to an element as the last child node
insertBeforeAdds a new child node to an element before a specified child node
replaceChildReplaces one child node of an element with another
removeChildRemoves a child node from an element
setAttributeAdds/modifies an attribute to an element
removeAttributeRemoves an attribute from an element
innerHTMLGets or sets the HTML content within an element
innerTextGets or sets the text content within an element

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top