// .innerHTML method is used to change the html contents of a DOM object
document.getElementById("demo").innerHTML = "Paragraph changed!";
// Try to use `textContent` instead of innerHTML as innerHTML can be hacked.
document.getElementById("myHeader").textContent = "Heading"
<box>
<p>Hello there!</p>
</box>
<script>
const box = document.querySelector('box');
// Outputs '<p>Hello there!</p>':
console.log(box.innerHTML)
// Reassigns the value:
box.innerHTML = '<p>Goodbye</p>'
</script>
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
//JavaScript can create dynamic HTML content:
<script>
document.getElementById("demo").innerHTML = "Date : " + Date(); </script>
</body>
</html>