JSFiddle - React, Tailwind, and code Playground
HTML
<div class="formSubmitButton">
<input type="submit" value="Submit">
</div>
JavaScript
// select the target node
var target = document.querySelector('div.formSubmitButton input[type="submit"]');
// create an observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation);
});
});
// configuration of the observer:
var config = { attributes: true, childList: true, characterData: true }
// pass in the target node, as well as the observer options
observer.observe(target, config);
// Triggering a change with JS on the target
target.style.color = 'red'