Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.
Well done!
You have completed (UPI) Chapter 9: Understanding the Document Object Model (DOM) with JavaScript!
Instruction
Using ID
An easy-to-use, fast, and exact method to locate an individual element is to mark the element with the id property in the HTML, e.g., <p id="p2">, and use this id as the parameter to getElementById(). The following code snippet will locate the element and display its content.
function show() {
"use strict";
const elem = document.getElementById("p2");
alert(elem.innerHTML);
}
...