title: JQuery - can i move array elements with jquery? and store them in an other array?
body: <p>Is it possible to move an array element with jquery? so if i click on it, it would append in the array aswell and not just visually on the dom?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var cardsInHand = ["1", "2", "3", "4", "5", "6", "7"];
  var cardsOnField = [];
  
  const cardsInHandEl = document.querySelector("#cardsInHand-el");
  
  for (var i = 0; i &lt; cardsInHand.length; i++) {
      cardsInHandEl.innerHTML +=
          `
      &lt;button&gt;
          ${cardsInHand[i]} 
      &lt;/button&gt;
      `
  }
  
  $(document).on("click", "#cardsInHand-el button", function () {
      $("#onField-el button")
          .remove()
      $(this)
          .appendTo($("#onField-el"));
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;body&gt;
      &lt;ul id="cardsInHand-el"&gt;Cards in Hand: &lt;/ul&gt;
      &lt;ul id="onField-el"&gt;&lt;/ul&gt;
      &lt;script src="script.js"&gt;&lt;/script&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>