<html>
<head>
<title>My Document</title>
<script type="text/javascript">
function change() {
const header = document.getElementsByTagName("H1").item(0);
header.firstChild.data = "A dynamic document";
const para = document.getElementsByTagName("P").item(0);
para.firstChild.data = "This is the first paragraph.";
const newText = document.createTextNode("This is the second paragraph.");
const newElement = document.createElement("P");
newElement.appendChild(newText);
para.parentNode.appendChild(newElement);
}
</script>
</head>
<body>
<input type="button" value="Change this document." onclick="change()">
<h1>Header</h1>
<p>Paragraph</p>
</body>
</html>