Web培训
400-996-5531
Mutation Observer类使用实例:
<div id="content"> <div id="loading">loading</div> </div> <script type="text/javascript"> var div = document.createElement("div"), container =document.getElementById("content"), loading =document.getElementById("loading"); var observer = new MutationObserver(function(mutations){ mutations.forEach(function(mutation){ var nodes = mutation.addedNodes; for(var i=0,len=nodes.length;i<len;i++){ var node = nodes[i]; if(node.parentNode.id==="content"){ alert("即将移除loading层"); container.removeChild(loading); } } }); }); observer.observe(document, { subtree: true, childList: true }); div.innerHTML = "新插入的内容"; container.appendChild(div); </script>
填写下面表单即可预约申请免费试听! 怕学不会?助教全程陪读,随时解惑!担心就业?一地学习,可全国推荐就业!
Copyright © 京ICP备08000853号-56 京公网安备 11010802029508号 达内时代科技集团有限公司 版权所有
Tedu.cn All Rights Reserved