I have been trying to log the updated cost information from an HTML document but have not been successful. I am sure it has to be that I am not using the mutation observer correctly. The js file is linked. Below is the HTML element that I am targeting.
HTML:
<span id="cost">0.00</span>
The JS file contains the following code:
const total = document.getElementById('cost');
console.log(total);
const options = {
characterData: true
};
function logCallback(mutations) {
console.log('called');
for (let mutation of mutations) {
if (mutation.type === 'characterData')
{
console.log('Mutation Detected: Price changed');
}
}
}
const observer = new MutationObserver(logCallback);
observer.observe(total.childNodes[0], options);