References > " . "Element Reference"; $pagetitle="Method"; $customsidebar = "elemref-xbl-sidebar.php"; include "header.php"; ?>

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:

id name

Attributes:

id

Type: element id, must be unique in the window

A unique identifier so that you can identify the 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().