Skip to content

Instantly share code, notes, and snippets.

@daltonnyx
Created January 16, 2017 04:27
Show Gist options
  • Save daltonnyx/45ea71f8207b39db4a3731f838aa4932 to your computer and use it in GitHub Desktop.
Save daltonnyx/45ea71f8207b39db4a3731f838aa4932 to your computer and use it in GitHub Desktop.
Mutation Observer
var dataContainer = document.getElementById('data-container');
var observer = new MutationObserver(function (mutations) {
var table = mutations[0].target.getElementsByTagName("TABLE")[0];
if (table != undefined) {
if (table.getElementsByTagName('tbody')[0].innerHTML.trim() == '') {
document.getElementById('upload-nsld').style.display = "none";
}
else {
document.getElementById('upload-nsld').style.display = "inline-block";
}
}
});
// configuration of the observer:
var config = { attributes: false, childList: true, characterData: false };
// pass in the target node, as well as the observer options
observer.observe(dataContainer, config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment