首页 > 其他 > 详细

dom元素改变监听

时间:2017-05-11 19:26:52      阅读:313      评论:0      收藏:0      [点我收藏+]
 function domChange(domId, callback) {
            // select the target node
            var target = document.getElementById(domId);
            // create an observer instance
            var observer = new MutationObserver(function (mutations) {
                mutations.forEach(function (mutation) {
                    callback();
                });
            });
            // configuration of the observer:
            var config = { attributes: true, childList: true, characterData: true };
            // pass in the target node, as well as the observer options
            observer.observe(target, config);
            // later, you can stop observing
            //observer.disconnect();
        }

 

dom元素改变监听

原文:http://www.cnblogs.com/gaocong/p/6842187.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!