Home > Element Reference : Method

Contents

### Method

Declares a JavaScript method that is added to the element's object. The method may take arguments, declared with the parameter element.

For example, an element that allows text to be selected might have getSelected and setSelected methods.

The example below is a method toUpper that, when called, will make the value attribute uppercase.

More information about Method

Example:

        <method name="toUpper">
          <body>
            var v = this.getAttribute("value");
            if (v != null) this.setAttribute("value",v.toUpperCase());
          </body>
        </method>

#### Attributes:

Attributes inherited from Element

class

The style class of the xbl:method. Multiple classes may be specified by separating them with spaces.

id

A unique identifier so that you can identify the xbl:method with. You can use this as a parameter to getElementById and other DOM functions and to reference the element in style sheets.

name

The name of the method, which is the name used in a script. For example, a method named setSize can accessed with object.setSize().

Copyright (C) 1999 - 2002 XULPlanet.com