<div id="name">1</div>
<div id="name">2</div>
<div id="name">3</div>
<div id="name">4</div>
<div id="name">5</div>
<div onclick="go();">click</div>
function go(){
var elemCount = document.getElementById("name").length;
for(let i = 0; i < elemCount; i++){
document.getElementById("name")[i].innerHTML = "qqq";
}
}