JS HTML DOM
The HTML DOM (Document Object Model) is a standard for how to get, change, add, or delete HTML elements.
Finding HTML Elements
JavaScript can access and manipulate HTML elements in several ways:
document.getElementById(id): Finds an element by element id.document.getElementsByTagName(name): Finds elements by tag name.document.getElementsByClassName(name): Finds elements by class name.
Example: Changing HTML Content
html
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>Test Yourself with an Exercise
Which method is used to find an HTML element by its id?