We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第471天 说说MutationObserver的应用场景有哪些?
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered:
MutationObserver用于监视Dom节点的变动情况,例:// 选择需要观察变动的节点const targetNode = document.getElementById('some-id');// 观察器的配置(需要观察什么变动)const config = { attributes: true, childList: true, subtree: true };// 当观察到变动时执行的回调函数const callback = function(mutationsList, observer) { // Use traditional 'for loops' for IE 11 for(let mutation of mutationsList) { if (mutation.type === 'childList') { console.log('A child node has been added or removed.'); } else if (mutation.type === 'attributes') { console.log('The ' + mutation.attributeName + ' attribute was modified.'); } }};// 创建一个观察器实例并传入回调函数const observer = new MutationObserver(callback);// 以上述配置开始观察目标节点observer.observe(targetNode, config);// 之后,可停止观察observer.disconnect();
Sorry, something went wrong.
性能统计、白屏统计、页面元素展示 自动化 埋点
No branches or pull requests
第471天 说说MutationObserver的应用场景有哪些?
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered: