const button:Element = document.createElement("button");//This works fine
const button:HTMLButtonElement = document.createElement("button");//This works too
const button2:Element = document.getElementsByTagName("button");//Why does this give an error?
const button3:HTMLButtonElement = document.getElementsByTagName("button");//And why does this one also give an error?
After using VS Code, I noticed that the interfaces missing classlist and autofocus property respectively. But then why is it acceptable when creating the element?
- How can I assign a variable to an existing element and add an event listener to it?