DOM methods
Last updated
Was this helpful?
Last updated
Was this helpful?
The DOM is not part of the JavaScript language, but is instead a Web API used to build websites.The DOM is not part of the JavaScript language, but is instead a Web API used to build websites.
The method getElementById()
returns an object representing the element whose property matches the specified string. Since element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly.
The getElementsByTagName
method of interface returns an of elements with the given tag name.
The method querySelector()
returns the first within the document that matches the specified selector, or group of selectors. If no matches are found, null
is returned.
The method querySelectorAll()
returns a static (not live) representing a list of the document's elements that match the specified group of selectors.