title: Why is my spin animation only working once when button is pressed?
body: <p>When the submit button is pressed, I need all the images to spin. However, this only happens the first time the button is pressed (until the next page refresh). I used jquery to add and remove class to the images when the button is pressed and the rotate animation is in my css.</p>
  <p>I shortened my code until this, what is wrong? Thanks in advance</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>function diceRoll() {
    $(".dice").removeClass("rotate");
    $(".dice").addClass("rotate");
  }
  
  document.getElementById("submit").addEventListener("click", function(e) {
    e.preventDefault();
  
    diceRoll();
  
  })</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>/* Images */
  
  img {
    width: 70px;
    line-height: 0;
    margin: 0 1%;
    display: flex;
    justify-content: center;
    display: inline;
  }
  
  figure {
    display: inline-block;
    vertical-align: middle;
  }
  
  .rotate {
    animation: rotation 0.1s infinite linear;
    animation-iteration-count: 2;
  }
  
  @keyframes rotation {
    from {
      transform: rotate(0deg);
    }
    to {
      transform: rotate(359deg);
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;title&gt;Diceey&lt;/title&gt;
  
  &lt;!-- Bootstrap, CSS --&gt;
  &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"&gt;
  &lt;link rel="stylesheet" href="styles2.css"&gt;
  
  &lt;!-- Jquery Links --&gt;
  &lt;script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"&gt;&lt;/script&gt;
  &lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
    &lt;div class="container-fluid heading"&gt;
      &lt;h1 id="title"&gt; Hello there&lt;/h1&gt;
      &lt;h5&gt;Press to roll dice&lt;/h5&gt;
    &lt;/div&gt;
  
    &lt;div class="container-fluid instructions"&gt;
  
      &lt;!-- Images --&gt;
      &lt;div class="container-fluid"&gt;
  
        &lt;div class="container-of-images"&gt;
          &lt;figure&gt;
            &lt;img id="img1" class="dice" src="https://image.ibb.co/nFqkvx/dice6.png"&gt;
          &lt;/figure&gt;
  
          &lt;figure&gt;
            &lt;img id="img2" class="dice" src="https://image.ibb.co/nFqkvx/dice6.png"&gt;
          &lt;/figure&gt;
  
          &lt;figure class="threeChoices"&gt;
            &lt;img id="img3" class="dice" src="https://image.ibb.co/nFqkvx/dice6.png"&gt;
          &lt;/figure&gt;
  
          &lt;figure class="fourChoices"&gt;
            &lt;img id="img4" class="dice" src="https://image.ibb.co/nFqkvx/dice6.png"&gt;
          &lt;/figure&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="container-fluid"&gt;
  
        &lt;div class="container-of-forms"&gt;
          &lt;a href="" id="submit" class="btn btn-info btn-lg" role="button"&gt;Go&lt;/a&gt;
        &lt;/div&gt;
        &lt;script src="index2.js" charset="utf-8"&gt;
        &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;footer&gt;
  &lt;/footer&gt;</code></pre>
  </div>
  </div>
  </p>