change all elements with a certain class based on text input

I think this is going to be something very simple but I haven’t found an answer. How would I make all span elements with class="namehere" display what was inserted in input text?

function start() {
  var name = document.getElementById("name").value;
  document.getElementByClassName("namehere").innerHTML = name;
<input id="name" type="text" value="Type name here">
<button type="button" onclick="start()">start</button>
<span class="namehere"></span> is doing this and that.
<span class="namehere"></span> wants to do this and that.
<span class="namehere"></span> is not doing this or that.
<span class="namehere"></span> wants to do this but instead is doing that.


The method getElementsByClassName() returns an array-like object of elements.

You need to iterate over each element and access it by its index.

Working Example

var nameElements = document.getElementsByClassName('namehere');
for (var i = 0; i < nameElements.length; i++) {
  nameElements[i].textContent = document.getElementById('name').value;


var nameElements = document.getElementsByClassName('namehere');, function (el) {
  el.textContent = document.getElementById('name').value;