简体   繁体   中英

jQuery - DOMSubtreeModified not working in chrome

i'm using the DOMSubtreeModified for listening to class change in my code:

$(document).ready(function(){
    var $window = $(window),
        $body   = $("body"),
        $footer = $("#footer");

    $("#header.main p, #container").click(function(){
        $("#cat.main").toggleClass("open");
        $("#container").toggleClass("rotate");
        if (!$("#container").hasClass("rotate")) {
            $("#container").removeAttr("class");
        }
    });

    function resize() {
        if($body.height() < $window.height()){
            $footer.addClass("fixed");
        } else {
            $footer.removeAttr("class");
        }
        $('#cat.main').bind('DOMSubtreeModified propertychange', function(e) {
            if ($("#cat.main").hasClass("open")) {
                $footer.removeAttr("class");
            } else {
                $footer.addClass("fixed");
        }
        });
    }
    $window
        .resize(resize)
        .trigger("resize");
});

and just notice that is not working in chrome! what's the alternative to DOMSubtreeModified?

to be clear i want something to work at least in ie9 too .

Thanks for your posting. In my experience , it is not related to Browser. I think this code is not working in other browsers too. Regarding to DOMSubtreeModified function, please check if "#cat.main" exists or created by AJax or something. This function will be running when this element exists on this page already.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM