Code to go logo
Created using Figma
Use Cases
Contribute
How to find element by class in JavaScript
DOM
By Jad Joubran ·
Last updated Mar 11, 2018
<div class="box"></div>
const element = document.querySelector(".box");
Mar 11, 2018
1
Jad Joubran
See answer
1
Jad Joubran
Document.querySelector
on MDN
Learn JavaScript step by step
Related use cases
How to find element by id in JavaScript
How to find multiple DOM elements in JavaScript
How to find an element from the DOM in JavaScript