Modifying HTML = Changing Elements, Attributes, Styles, and Events.
Modifying the HTML DOM can be many different things
In the next chapters we will take a closer look at the most common ways to modify the HTML DOM.
The easiest way to change the content of an element is by using the innerHTML property.
The following example changes the HTML content of a <p> element:
| The examples are explained in details in the next chapters. |
With the HTML DOM you can access the style object of HTML elements.
The following example changes the HTML style of a paragraph:
<p id="p2">Hello world!</p>
<script>
document.getElementById("p2").style.color="blue";
</script>
</body>
</html>
To add a new element to the HTML DOM, you must create the element (element node) first, and then append it to an existing element.
Your message has been sent to W3Schools.