title: AppendChild in `for` loop or `forEach `
body: <p>I have several classes with <code>single-product</code> as className. I am trying to add the buttons to all of them using <code>appendChild</code> in <code>for loop</code> in javascript. But it doesn't seem to be working. I don't understand why?<br>I am taking them in an array using <code>querySelectorAll</code>.<br>
  <code>let products = document.querySelectorAll('.single-products')</code> then I created an element <code>div</code> which contains my button.<br></p>
  <pre><code>let button = document.createElement('div');
  button.innerHTML = &quot;&lt;a class='btn hero-btn'&gt;Add to cart&lt;/a&gt;&quot;;
  for (let i=0 ; i &lt; products.length ; i++){document.querySelectorAll('.single-product')[i].appendChild(button.cloneNode())
  </code></pre>
  <p>I also tried <code>forEach</code> with <code>this</code> as the param but even that did not work.</p>