Kong
Kong

Reputation: 23

TS2339: Property 'width' does not exist on type 'HTMLDivElement'

enter image description here

What should I do

 this.container = document.getElementById(obj.id) as HTMLDivElement;   
 this.containerWidth =this.container.width;
 this.containerHeight = this.container.height

Upvotes: 0

Views: 2467

Answers (1)

Viet
Viet

Reputation: 12797

You can use offsetWidth: offsetWidth and offsetHeight

this.containerWidth =this.container.offsetWidth;
this.containerHeight = this.container.offsetHeight

You saw this error because HTMLElement don't have property width.

Upvotes: 1

Related Questions