const p = document.getElementByClassName("bar"); console.log(p[1].innerHTML); <p class="bar">first</p> <p class="bar">second</p> <p class="bar">third</p> <p class="bar">fourth</p>