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
It is not the best way but it works.
function MyElement(){ var element = document.createElement("div"); element.viewInner = function(){ console.log(this, this.innerHTML) }; return element; } var test = new MyElement(); test.innerHTML = "Hi"; test.viewInner(); // Hi 0 讨论(0) 查看其它4个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复