how to detect changes in a div javascript

Solutions on MaxInterview for how to detect changes in a div javascript by the best coders in the world

showing results for - "how to detect changes in a div javascript"
Gaia
17 Feb 2018
1
2
3  Press enter
4
5
6  var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
7  var list = document.querySelector('ol');
8
9  var observer = new MutationObserver(function(mutations) {
10    mutations.forEach(function(mutation) {
11      if (mutation.type === 'childList') {
12        var list_values = [].slice.call(list.children)
13            .map( function(node) { return node.innerHTML; })
14            .filter( function(s) {
15              if (s === '<br />') {
16                return false;
17              }
18              else {
19                return true;
20              }
21        });
22        console.log(list_values);
23      }
24    });
25  });
26
27  observer.observe(list, {
28  	attributes: true,
29  	childList: true,
30  	characterData: true
31   });
32
33