getElementById
getElementById is a method of the Document interface in the Document Object Model (DOM). It returns a reference to the element whose id attribute matches the provided string, or null if no such element exists. The id value is expected to be unique within a document.
Usage is straightforward: var el = document.getElementById('myId'); if (el) { el.textContent = 'Hello'; } This pattern is common for accessing
Notes and behavior: getElementById searches the current document for an element with the given id. Because
Compatibility and alternatives: The method is supported by all major browsers. For more flexible selection, developers