getElementById method

Element? getElementById(
  1. String elementId
)

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

If you need to get access to an element which doesn't have an ID, you can use Document.querySelector to find the element using any .

Note: IDs should be unique inside a document. If two or more elements in a document have the same ID, this method returns the first element found.

Implementation

external Element? getElementById(String elementId);