Course Content
Chapter 2: Selecting
What elements do you want to select?
0/32
JavaScript for Optimizers
About Lesson

HTML

<div>Div 1</div>
<div class="classElement">Div 2</div>
<div>Div 3</div>

JavaScript

let getClassElement = document.querySelector(".classElement");
console.log(getClassElement.innerText);

Console

"Div 2"
Exercise Files
No Attachment Found
No Attachment Found
0% Complete