var addtocartbuttons = document.getElementsByClassName(`cart`)
    for (let i = 0; i < addtocartbuttons.length; i++) {
      var button = addtocartbuttons[i]
      button.addEventListener(`click`, lang1)
    }
    function lang1(event) {
      var target = event.srcElement;
      var button = event.target
      var shopitem = button.parentElement.parentElement.parentElement
      var title = shopitem.getElementsByClassName(`title`)[0].innerText;
      console.log(title)
      res2 = document.getElementsByClassName(`result2`)
      res2.textContent = title
      console.log(res2)
    }  
  <div class="product-categorie-box">
    <div class="tab-content">
      <div role="tabpanel" class="tab-pane fade show active" id="grid-view">
        <div class="row">
          <div class="col-sm-6 col-md-6 col-lg-4 col-xl-4">
            <div class="products-single fix">
              <div class="box-img-hover">
                
                <img src="../../petuta/pizza/margerita.jpg" class="img-fluid" alt="Image">
                <div class="mask-icon">
                  <ul>
                    <li><a href="#" data-toggle="tooltip" data-placement="right" title="View"><i class="fas fa-eye"></i></a></li>
                    <li><a href="#" data-toggle="tooltip" data-placement="right" title="Compare"><i class="fas fa-sync-alt"></i></a></li>
                    <li><a href="#" data-toggle="tooltip" data-placement="right" title="Add to Wishlist"><i class="far fa-heart"></i></a></li>
                  </ul>
                  <a class="cart" href="#">Add to Cart</a> </div>
              </div>
              <div class="why-text">
                <h4 class="title" id="title1"> Kids</h4>
                <h5 class = "price"> €6.00</h5>
              </div>
            </div>
          </div>but when button is pressed the text content in res2 despairs and put the new data any ideas?
Here is the console.log:
(HTMLCollection [div.result2, textContent: "Olives"]
0: div.result2
length: 1
textContent: "Olives")
The array only stays of the length of 1 I want it to keep storing how can I do that? I want to store the text content in res2 even when the button is clicked. I'm making a website which sends email with an order, and when I send email only the first one get sends and even in the console it appears the length of 1 then gets reset when add to cart button is clicked. ps. i have 33 of these product-categorie-box so I would need some fix I didnt use get element by id i used get element by class yet i still get one only can
