getElementsByClassName()
method returns a collection of all elements (as an array) in the document with the specified class name.
JSvar arr = document.getElementsByClassName("demo");
//accessing the second element
arr[1].innerHTML = "Hi";
HTML<div class="demo">1</div>
<div class="demo">2</div>