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')
}
Advertisement
Answer
the onchange event only works on inputs, selects and textareas. You will need another event.