Zackline
Zackline

Reputation: 834

KotlinJS unresolved reference element.style

I want to change the style of an element created using document.createElement("button").

I tried using:

element.style.width = "50px"

However, the style field cannot be found.

Upvotes: 0

Views: 384

Answers (1)

Zackline
Zackline

Reputation: 834

The Element needs to be cast to the more specific HTMLElement type:

val button = document.createElement("button") as HTMLElement
button.style.width = "50px"

Upvotes: 3

Related Questions