xxxxxxxxxx
var elementsArray = document.getElementsByClassName("student.age");
var elementsArray = document.getElementsByClassName("student");
var elementsArray = document.getElementsByClassName("age");
xxxxxxxxxx
<!DOCTYPE html>
<html>
<body>
<div class="myclass">The value is presented inside the class</div>
<button onclick="RetriveByClassName()" id="btnClick">Click</button>
<script>
function RetriveByClassName() {
var x = document.getElementsByClassName("myclass");
alert(x[0].innerHTML);
}
</script>
</body>
</html>
xxxxxxxxxx
var priceEls = document.getElementsByClassName("price");
for (var i = 0; i < priceEls.length; i++) {
var price = priceEls[i].innerText;
alert("Price: " + price);
}