DOM methods

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.

getElementById

The Document method getElementById() returns an Element object representing the element whose id 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.

getElementsByTagName

The getElementsByTagName method of Document interface returns an HTMLCollection of elements with the given tag name.

querySelector

The Document method querySelector() returns the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned.

querySelectorAll

The Document method querySelectorAll() returns a static (not live) NodeList representing a list of the document's elements that match the specified group of selectors.

References

Last updated