get elements by class name first element code example
Example 1: js get first element by class
var elements = document.getElementsByClassName('className');
var requiredElement = elements[0];
Example 2: get element by id inside first element by class
var targetDiv = document.getElementById("foo").getElementsByClassName("bar")[0];