Animations
API
Arrays
Async
Basics
Challenges
Classes
Console
Dates
Debugging
DOM Elements
DOM Methods
DOM Properties
Event Listeners
Flow Control
Forms
Functions
Global Functions
JSON
Keywords
Libraries (3rd party)
Math
Modules
Objects
Snippets
String
Types
Widgets
Window Object
When you use the getElementsByClassName()
method, will get a list(array) of all the elements with that matching CSS class.
Using the code below, we will look and see what the contents of paragraphs 1 & 2 are.
Someone who'll rattle the cages. How about a magic trick? I'm gonna make this pencil disappear. Ta-da!
You have learn to bury your guilt with anger. I will teach you to confront it and to face the truth.
let x = document.getElementsByClassName("lead");
let results = "";
results = "The first paragraph (index 0) which has the lead class is: " + x[0].innerHTML + "
";
document.getElementById("demo1").innerHTML = results;