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

removeBehavior method

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


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


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:
    <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 ("");

        function RemoveBehaviors () { 
            for (i=0; i < divElems.length; i++) {
                if (divElems[i].removeBehavior) {
                    divElems[i].removeBehavior (behaviorIDs [i]);
    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>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content