get first element by class name code example
Example 1: how to get element by class name javascript
document.getElementsByClassName("legend").style.display="none";
Example 2: js get first element by class
var elements = document.getElementsByClassName('className');
var requiredElement = elements[0];