Examples and Challenges:
Examples:
The DOM:
- Call an object by its id then insert text:
- Call an object by its id then create text:
- Call an object by its class then change styling of one element of the class:
- Call an object by its tag then alter its styling:
document.getElementById("id-name")
See the code by clicking the button.
document.getElementById("id-name")
See the code by clicking the button.
document.getElementsByClassName("class-name")
Am I black?
Am I blue?
Am I red?
See the code by clicking the button.
document.getElementsByTagName("tag")
See the code by clicking the button.
Challenges:
The DOM:
- Call an object by its id then insert image:
- Call an object by its name then print how many of them there are:
- Create a block of code that stops the function reproducing its contents upon multiple clicks of the button:
See the Pen abZNRJW by Justin Sawyer (@JustinSawyer) on CodePen.
See the Pen How many names? by Justin Sawyer (@JustinSawyer) on CodePen.
See the Pen create a block of code that stops the function reproducing its contents upon multiple clicks of the button by Justin Sawyer (@JustinSawyer) on CodePen.