You’re not specific about what you mean by “changed”, because my answer could be different based on that but this covers (almost) any change.
With outerHTML
:
var a = document.getElementById("elementID").outerHTML;
setInterval(function() {
// checks the stored text against the current
if (a !== document.getElementById("elementID").outerHTML) {
alert("There has been a new message.");
// do your stuff
}
// updates the global var to store the current text
a = document.getElementById("elementID").outerHTML;
}, 150); //define your interval time, every 0.15 seconds in this case