Example: Making changes to objects
Notice in the consoleA window used for debugging, usually not visible on the page. how the third use of console.log
does not result in anything being written. This is a result of using innerHTML
.
The first time we use setAttribute
, we specify that we are changing the style. A cleaner approach is the second use, where we predefine a classAn attribute used to refer to a group of elements. in a CSS file and then use setAttribute
to change the class of the element.
Note:
Hints:
- undefined
1
2
var redLargeNode = document.getElementById("redlarge");
var blueNode = document.getElementById("blue");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
.strange {
color: orange;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX