I am making a DOM based game for the first time. I would like to extend HTMLDivElement, however in TypeScript, HTMLDivElement is an Interface.
I would like to do this p
A bit late, but apparently it's still not possible to extend HTMLDivElement. A simple way to solve extending a DIV: just use CSS to make a generic HTMLElement behave like a div.
CSS
my-element {
display:block;
}
Javascript
class MyElement extends HTMLElement{
constructor(){
super()
this.innerHTML = "I behave exactly like a div"
}
}
window.customElements.define('my-element', MyElement);