Step 8
-
Preferably, we want the "output" to be hidden until we click on the
zzzbutton. -
Hiding the output is simple; add the following
displayproperty to the style selector for output.
.output {
border: 3px solid white;
margin: 1em 5em 1em 5em;
display: none;
}
-
Save the
index.htmlfile; refresh theindexpage in the browser. -
Update the
handleOnClickEventfunction as follows:
<script>
function handleOnClickEvent() {
let output = document.querySelector(".output");
output.style.display = "block";
}
</script>
The
documentobject is the root node of the HTML document. When an HTML document is loaded into a browser, it becomes adocumentobject. Thedocumentobject is also called the DOM (Document Object Model).The
querySelector()method returns the first element of DOM that matches a specified CSS selector in the document.
- Save the
index.htmlfile; refresh theindexpage in the browser. Notice the output is hidden until you click on thezzzbutton.