section DOM section

Description

Extensions to DOM elements, plus other utilities for DOM traversal and modification.

Prototype's DOM extensions represent a large portion of where you'll spend your time. Prototype adds many convenience methods to elements returned by the $ function. For instance, you can write

$('comments').addClassName('active').show();

to get the element with the ID of comments, add a class name to it, and show it (if it was previously hidden).

In other words, Prototype adds "instance" methods to DOM nodes. This is made possible by direct extension of the backing DOM objects (in browsers that support it) and by manual extension of individual nodes (in browsers that do not).

Namespaces

  • document

    Prototype extends the built-in document object with several convenience methods related to events.

  • Form

    Utilities for dealing with forms in the DOM.

  • Abstract

Classes

  • Element

    The Element object provides a variety of powerful DOM methods for interacting with DOM elements — creating them, updating them, traversing them, etc. You can access these either as methods of Element itself, passing in the element to work with as the first argument, or as methods on extended element instances:

  • Event

    The namespace for Prototype's event system.

  • Selector

    A class that queries the document for elements that match a given CSS selector.