The getElementById()
is a JavaScript function that lets you grab an HTML element, by its id
, and perform an action on it. The name of the id
is passed as a parameter, and the corresponding element is the return value.
The following code shows how the function can be used. The color of the box, with the content id
, changes once the action button is clicked.