0

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
  • Please provide a comment on how this question could be improved or whether sharing knowledge QA style is not appreciated instead of just downvoting. Commented Dec 18, 2017 at 14:45

1 Answer 1

3

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

val button = document.createElement("button") as HTMLElement
button.style.width = "50px"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.