[英]trigger onchange event for span not working
I am trying to trigger the onchange event on a span element.我正在尝试在 span 元素上触发 onchange 事件。 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. onchange 事件仅适用于输入、选择和文本区域。 You will need another event.
您将需要另一个事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.