Hello I have this piece of code in TypeScript
var btn = document.getElementsByClassName("btn-up") as EventTarget;
btn.addEventListener('click', (event) => {
console.log('clickcc');
})
And It throws me this error * Type 'HTMLCollectionOf' is missing the following properties from type 'EventTarget': addEventListener, dispatchEvent, removeEventListener *
Please how to fix it?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.