KotlinJS unresolved reference element.style

396 views Asked by At

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.

1

There are 1 answers

0
Zackline On BEST ANSWER

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

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