Building an Animated Robot
The first step is to select the element you want to apply or change a style on. In Chapter 5, we show you how to do this using getElementById. For example, to select Douglas’s left eye, you can use the following code:
document.getElementById("lefteye").style.backgroundColor = "purple";
- If the CSS property has dashes (-), the CSS property name gets converted to camelCase. So, background-color gets changed to backgroundColor ...