Java Reference
In-Depth Information
Summary
In this chapter we have learned the following:
• The Document Object Model is a way of representing a page of HTML as a tree of
nodes.
• The
document.getElementById
,
docu-
ment.getElementsByClassName
,
docu-
ment.getElementsByTagNames
, and
document.querySelector
can
be used to access elements on a page.
• The
parentNode
,
previousSibling
,
nextSibling
,
childNodes
, and
children
methods can be used to navigate around the DOM tree.
• An element's attributes can be accessed using the
getAttribute()
method and
updated using the
setAttribute()
method.
• The
createElement
and
createTextNode
methods can be used to create dy-
namic markup on the fly.
• Markup can be added to the page using the
appendChild
and
insertBefore
methods.
• Elements can be replaced using the
replaceChild
method and removed using
the
removeChild
method.
•
innerHTML
can be used to insert a large chunk of raw HTML directly into the
DOM.
• The CSS properties of an element can be changed by accessing the
style
property.
Now that we've learned how to find and change the markup of a web page, it's time to start
interacting with it. In the next chapter we'll be covering a fundamental part of the JavaScript
language: events.
[1]
The DOM can also be used to represent XML and XHTML documents.

