Monday, January 16, 2012

How to recursively disable all of elements inside a div by Javascript?

<script type="text/javascript">

    $('#readonlydiv').ready(function () {

        RecursiveDisable(document.getElementById("readonlydiv"));

    });



    function RecursiveDisable(element) {

        try {

            element.disabled = element.disabled ? false : true;

        }

        catch (E) {

        }

        if (element.childNodes && element.childNodes.length > 0) {

            for (var x = 0; x < element.childNodes.length; x++) {

                RecursiveDisable(element.childNodes[x]);

            }

        }

    }

No comments:

Post a Comment