Windows Script Components  

element Property

Returns the element to which the behavior is being applied.

[oElement ] Behavior.element

Values

oElement
Element to which the behavior is being applied.
Behavior
The ID of the <implements> element used to implement the Behavior interface.
Note   By default, the properties and methods exposed by the Behavior handler are automatically added to the global script namespace and can be accessed without referencing the Behavior handler ID. In this case, instead of using Behavior.element as shown in the syntax, the property can be used in script simply as element. For more details, see the <implements> element.

Remarks

The property is read-only.

With this property, a behavior is able to communicate with the containing document. All properties, methods, and events exposed by the DHTML object model are accessible through this property.

Example

The following script component fragment implements an expanding and collapsing table of contents using a script component. The script component attaches to the element's DHTML onmouseover event. It sets the DHTML cursor property of the element to "hand" to signal the user that the element can be clicked in order to toggle visibility of its children.

Note   A CDATA section is required to make the script in the <script> element opaque. For details, seeScript Component Files and XML Conformance.
<public>
   <attach event="onmouseover" handler="event_onmouseover");
</public>

<implements type="Behavior"/> 
<script language="JScript">
<![CDATA[
   function event_onmouseover()
   {
      oElement = window.event.srcElement;
      if (oElement == element)
         oElement.style.cursor = "hand";
   }
]]>
</script>

See Also

For general information about applying behaviors to DHTML elements, see the "Using DHTML Behaviors" topic on the Site Builder Network (SBN)