Mutationobserver add element changes code example

Example: mutationobserver js

var targetNode = document.getElementById('myID');
var config = { attributes: true };
var observer = new MutationObserver(function (mutations) {
  for (let mutation of mutations) {
    if (targetNode.style.visibility == 'visible') {
      document.getElementById('myID1').style.display = 'block';
      document.getElementById('myID2').style.display = 'block';
    }
    else {
      document.getElementById('myID1').style.display = 'none';
      document.getElementById('myID2').style.display = 'none';
    }
  }
});

observer.observe(targetNode, config);