title: Calculate and apply darker background color using javascript
body: <p>I want to apply darker shades background dynamically using javascript. For that I have written below 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-css lang-css prettyprint-override"><code>.event-list .bg{
  background:#eee;
  padding:5px;
  }
  
  .grid .event-list:first-child .bg{
   background: #2aac97
  }
  .grid .event-list:nth-child(2) .bg{
   background: #29a4ac
  }
  .grid .event-list:nth-child(3) .bg{
   background: #2a92ac
  }
  .grid .event-list:nth-child(4) .bg{
   background: #2a7dac
  }
  .grid .event-list:nth-child(5) .bg{
   background: #2967ac
  }
  .grid .event-list:nth-child(6) .bg{
   background: #2a55ac
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="grid"&gt;
    &lt;div class="event-list row"&gt;
      &lt;div class="bg"&gt;Lorem Ipsum&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="event-list row"&gt;
      &lt;div class="bg"&gt;Lorem Ipsum&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="event-list row"&gt;
      &lt;div class="bg"&gt;Lorem Ipsum&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="event-list row"&gt;
      &lt;div class="bg"&gt;Lorem Ipsum&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="event-list row"&gt;
      &lt;div class="bg"&gt;Lorem Ipsum&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have done this using css, but content coming from backend I want to use javascript. What should I do for this.</p>