set id a partir getElementsByClassName code example
Example 1: get element by class
var elements = document.getElementsByClassName(names); // or:
var elements = rootElement.getElementsByClassName(names);
Example 2: js get element by class
document.getElementsByClassName('Name');