Приглашаем посетить
Тургенев (turgenev-lit.ru)

Document Element Collections

Chapter 7

Document Element Collections

The Dynamic HTML object model represents the document's structure through a set of collections exposed on the document object. These collections provide access to all HTML elements contained within the document. Understanding how these collections relate to the HTML source code and how to access these collections is the first step to programming the HTML document. This chapter shows you how to manipulate the document element collections as well as how Microsoft Internet Explorer 4.0 parses the document.

Consider the following short HTML document:

<HTML>
   <HEAD>
      <TITLE>Document Structure</TITLE>
   </HEAD>
   <BODY>
      <H1>Overview</H1>
      <P>Examining an HTML document</P>
   </BODY>
</HTML>

The object model provides a way to access the HTML, Head, Title, Body, H1, and Paragraph elements and thereby modify their attributes. The markup, like all aspects of the document, is accessed using the document object introduced in Chapter 6, "The HTML Document." The document object exposes an all collection that represents every element in the document and several filtered collections that represent a subset of the document's elements. For example, the forms collection contains only the Form elements. In addition, developers can create their own custom collections of document elements.

The ability to access any element in the document is a key innovation in Dynamic HTML. Until Dynamic HTML, scripts could manipulate only the set of elements deemed interesting by vendors developing the browsers. Now Web developers have complete control over the page and can decide for themselves what is interesting. They can filter the all collection and manipulate any set of elements as a group, removing all limitations and providing universal access to the document.

The following topics are covered in this chapter:

[Содержание]