Home > Element Reference : Property

Contents

### Property

Declares a JavaScript property that is added to the element's object. The property element may have a getter child element and a setter child element to get and set the value of the property respectively.

For example, you might want to add a selected property to a drop-down box. Properties make it convenient if an object is going to be used a lot with scripts.

The property element may have content which is code that determines the initial value of the property.

More information about Property

#### Attributes:

Attributes inherited from Element

class

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

id

A unique identifier so that you can identify the xbl:property 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 property, which is the name that can be used via a script. For example, if a property has the name color, it can be accessed with object.color, where object is a reference to the object.

onget

The code contained in the onget attribute is called when an attempt is made to retrieve the value of the property. You may use this attribute when only a simple script is required. For longer scripts, you should use the getter element, which functions similarly. The onget code should return the value of the property.

onset

The code contained in the onset attribute is called when an attempt is made to modify the value of the property. You may use this attribute when only a simple script is required. For longer scripts, you should use the setter element, which functions similarly. Within the code of the onset attribute, the variable val is set to the value that the property should be changed to.

readonly

If set to true, the value of the property can not be changed. If set to false, the property may be changed.

Copyright (C) 1999 - 2002 XULPlanet.com