Skip to content

Commit 36d1288

Browse files
authored
Merge pull request #81 from cdmain/patch-5
Update A-the-dom.md
2 parents a3e0ed2 + 7310bbe commit 36d1288

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lessons/05-putting-it-all-together/A-the-dom.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ redSquare.style.backgroundColor = "limegreen";
6464

6565
Notice that, despite the CSS class dictating that the `div` should be `crimson` colored, it's actually `limegreen`. This is because we used JavaScript to change the color of it. So let's break it down.
6666

67-
- We called a method on `document`. `document` is a globally available variable in the browser that you use to interact with the HTML and CSS. It a lot of methods that you can use. In this case, we're using the `querySelector` in which you pass in a CSS selector and it returns to you the **first** one of that matches selector that it finds (if you have many of them on the page, you get just the first one.)
67+
- We called a method on `document`. `document` is a globally available variable in the browser that you use to interact with the HTML and CSS. It has a lot of methods that you can use. In this case, we're using the `querySelector` in which you pass in a CSS selector and it returns to you the **first** one of that matches selector that it finds (if you have many of them on the page, you get just the first one.)
6868
- From there, we have a JavaScript pointer to the `div.red-square` tag stored in the `redSquare` variable which means we can start manipulating it.
6969
- We then use the `style` object which represents all the CSS styles that are being applied to that object at that time.
7070
- We then set the `backgroundColor` of that element. Notice it is `backgroundColor` and not `background-color` (camelCasing vs kebab-casing). This is how you interact with CSS via JavaScript. Anything that's kebab-cased like `padding-right` becomes camelCased, like `paddingRight`. While annoying, it'd be even more annoying if they didn't switch it since everything in JavaScript is camelCased.

0 commit comments

Comments
 (0)