Skip to content

trigger onchange event for span not working

I am trying to trigger the onchange event on a span element. The event is not triggered at all. How can I make it happen? Here is my code:

First method I tried

  document.getElementById(seconds).addEventListener('change', (event: MutationEvent & { path: any }) => {
console.log('span has changed')

Second method

document.getElementById(seconds).onchange((event) => {
console.log('span has chanegd')


the onchange event only works on inputs, selects and textareas. You will need another event.