我是靠谱客的博主 无情音响,这篇文章主要介绍关于DOMContentLoaded死活无效的解决方案,现在分享给大家,希望可以做个参考。

 let observer = new MutationObserver( (mutationRecords) => {
                for (let mr of mutationRecords) {
                    for (let el of mr.addedNodes) {
                        if (el.nodeName === 'DIV') {
                             alert("DOMNodeInserted DIV") 
                        }
                    }
                }
            })
            observer.observe(document.body, {childList:true, subtree: true})  

在document未加载完成等情况下无法使用DOMContentLoaded,可以用如上api代替

最后

以上就是无情音响最近收集整理的关于关于DOMContentLoaded死活无效的解决方案的全部内容,更多相关关于DOMContentLoaded死活无效内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部