To access an HTML element, JavaScript can use the document.getElementById(id) method.
The id attribute identifies the HTML element, and the innerHTML property defines the HTML content inside that element.
Example
<!DOCTYPE html> |
After an HTML document has loaded, utilizing document.write() will remove all existing HTML content. |
Example
<!DOCTYPE html> |
Reserve the use of the document.write() method solely for testing purposes. |