HTML and CSS Reference
In-Depth Information
Open the console, and type in this
code:
document.getElementById('first');
As you can see, the getElementById
method returns an object. This
object also has methods and prop-
erties that you can call:
var d =
document.getElementById('first');
console.log(d.innerHTML);
The elements inside the <div> can
also be accessed through methods
and properties of the element.
This code grabs the first child of
the <div> :
var h = d.children[0]
The DOM isn't just a
way to access the docu-
ment. You can also use
it to modify the page.
Here's a quick example.
 
Search WWH ::




Custom Search