Returns a reference to the tag in the primary document to which the behavior is attached.
All properties, methods, and events of the element to which the behavior is attached are accessible to HTML Component (HTC) using this object. The element object is the default object of properties, methods, or event names specified in the HTC. Therefore, they can be specified directly, without using the element keyword.
This example uses a behavior to implement a table of contents that expands and collapses when the user clicks it. The HTC attaches to the element's onmouseover event and sets the color property of the element to red. The color of the element can be toggled through the style object directly, instead of referring to it as element.style.
The HTC also sets the cursor property to "hand" to signal the user that the element can be clicked to toggle visibility of its children.
<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="Hilite" />
prevColor = style.color;
element.style.color = "red";
element.style.cursor = "hand";
This feature requires Microsoft® Internet Explorer 5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.
Introduction to DHTML Behaviors, Implementing DHTML Behaviors in Script