【发布时间】:2016-03-26 19:53:27
【问题描述】:
使用 MutationObserver 我侦听树中的节点插入,但它在插入节点后运行。
如果我想在节点插入节点之前运行一个事件,我会怎么做?
例如
// create an observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation.type);
});
});
// configuration of the observer:
var config = { subtree: true };
// pass in the target node, as well as the observer options
observer.observe(document.documentElement, config);
该事件类似于 DOMNodeInserted 但如果我想要“BeforeDOMNodeInserted”之类的东西?
像“beforescriptexecte”Firefox 监听器。
【问题讨论】:
标签: javascript dom nodes