title: Star rating system save value on click
body: <p>I'm trying to make a star rating system, i have this code and i want to make some changes on it, after the user clicks on the stars it shows an alert with how many stars and it resets the colors, what i want is the color filling to stay after the user clicks on it, and replace the alert with a div under the stars, here is my code: </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() {
      $("div.star-rating &gt; s, div.star-rating-rtl &gt; s").on("click", function(e) {
          var numStars = $(e.target).parentsUntil("div").length+1;
          alert(numStars + (numStars == 1 ? " star" : " stars!"));
      });
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.star-rating s:hover {
      color: red;
  }
  .star-rating-rtl s:hover {
      color: red;
  }
  
  .star-rating s,
  .star-rating-rtl s {
      color: black;
      font-size: 50px;
      cursor: default;
      text-decoration: none;
      line-height: 50px;
  }
  .star-rating {
      padding: 2px;
  }
  .star-rating-rtl {
      background: #555;
      display: inline-block;
      border: 2px solid #444;
  }
  .star-rating-rtl s {
      color: yellow;
  }
  .star-rating s:hover:before, .star-rating s.rated:before {
      content: "\2605";
  }
  .star-rating s:before {
      content: "\2606";
  }
  .star-rating-rtl s:hover:after, .star-rating-rtl s.rated:after{
      content: "\2605";
  }
  .star-rating-rtl s:after {
      content: "\2606";
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="star-rating"&gt;&lt;s&gt;&lt;s&gt;&lt;s&gt;&lt;s&gt;&lt;s&gt;&lt;/s&gt;&lt;/s&gt;&lt;/s&gt;&lt;/s&gt;&lt;/s&gt;&lt;/div&gt;
  &lt;div class="star-rating-rtl"&gt;&lt;s&gt;&lt;s&gt;&lt;s&gt;&lt;s&gt;&lt;s&gt;&lt;/s&gt;&lt;/s&gt;&lt;/s&gt;&lt;/s&gt;&lt;/s&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>