简体   繁体   English

jQuery - DOMSubtreeModified 在 chrome 中不起作用

[英]jQuery - DOMSubtreeModified not working in chrome

i'm using the DOMSubtreeModified for listening to class change in my code:我正在使用 DOMSubtreeModified 来监听代码中的类更改:

$(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!请注意,这在 chrome 中不起作用! what's the alternative to DOMSubtreeModified? DOMSubtreeModified 的替代方案是什么?

to be clear i want something to work at least in ie9 too .需要明确的是,我也希望至少在 ie9 中也工作

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.关于 DOMSubtreeModified 函数,请检查“#cat.main”是否存在或由 AJax 或其他东西创建。 This function will be running when this element exists on this page already.当此元素已存在于此页面上时,此函数将运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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