Created
January 16, 2017 04:27
-
-
Save daltonnyx/45ea71f8207b39db4a3731f838aa4932 to your computer and use it in GitHub Desktop.
Mutation Observer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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