Skip to content
Advertisement

variable (element).style is undefined

JavaScript

why it says variable (element).style is undefined? I tried .style.color=”red”; on a different code & it works!

Advertisement

Answer

  • First you have to compare against counter.innerHTML because you update its value.
    The value of counter doesn’t change and will all the time be 10 as you can see in the snippet below.

  • Second the value of number is counter.innerHTML;


JavaScript

This means that is does not have a style.color property instead you should set the style.color of your counter element.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement