you’re on your way �
223
the document object model
OK, I get all this business about a web
browser seeing my pages as trees... but
how does that really help me? I need to
change a web page, not grow one.
See? If you want to understand web
pages, you have to master trees.
Mike: Often, the root must be watered carefully
before one can enjoy the leaf.
Jenny: What the heck does that mean?
Mike: Honestly, I have no idea. I read it somewhere,
and thought that it might impress you. Anyway... since
web browsers view your pages as trees, you need to be
able to write code that works on those trees. And that’s
where the Document Object Model comes in.
Jenny: OK, now we’re talking. That’s what I came
here to nd out about... the Document Object Model.
Mike: The Document Object Model—usually called
the DOM for short—is how you can work on the tree
that the browser creates from your web page. You can
manipulate the DOM with JavaScript, and update the
browser’s tree. And once you update the tree, the page
itself will automatically be changed by the browser,
without any page reloading or refreshing.
There’s a group called the
World Wide Web Consortium
(most people call them
the W3C for short) that
publishes the specications
and standards for the DOM.
Just a bit of trivia for you
standards gurus out there...