You are here: Reference > JavaScript > client-side > HTML DOM > methods > removeBehavior

removeBehavior method

Browser support:
Removes the specified behavior from the current element.

Syntax:

object.removeBehavior (behaviorID);
You can find the related objects in the Supported by objects section below.

Parameters:

behaviorID
Required. Specifies the identifier returned by the addBehavior method.

Return value:

Boolean. One of the following values:
false Cannot remove the behavior.
true The remove operation was successful.

Example HTML code 1:

This example shows how to add and remove behaviors:
Code
hover.htc
<head>
    <script type="text/javascript">
        var behaviorIDs = [];
        var divElems = [];

        function SetBehaviors () {
            divElems = document.getElementsByTagName ("div");
            for (i=0; i < divElems.length; i++) {
                if (divElems[i].addBehavior) {
                    behaviorIDs[i] = divElems[i].addBehavior ("hover.htc");
                }
            } 
        }

        function RemoveBehaviors () { 
            for (i=0; i < divElems.length; i++) {
                if (divElems[i].removeBehavior) {
                    divElems[i].removeBehavior (behaviorIDs [i]);
                }
            }
        }
    </script>
</head>
<body>
    You can add behaviors to the div elements with this button:
    <button onclick="SetBehaviors ();">Add behaviors!</button>
    <br /><br />
    Hover your mouse over the div elements!
    <br /><br />
    Use this button to remove behaviors:
    <button onclick="RemoveBehaviors ();">Remove behaviors!</button>
    <br /><br />
    <div>1. division</div>
    <div>2. division</div>
    <div>3. division</div>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content