Javascript - changing background color opacity with time interval
<p>I am trying to add the background color to a <code>.top-barz</code> element when I click on another element, but I would like to make that as an animation in duration of 1s. I am pretty new to javascript and not sure how to do that?</p>

<p>I would like to animate from change opacity of <code>rgba(36,36,36, .1)</code> to <code>rgba(36,36,36, 1)</code></p>

<p>I have come up with this code and put it  into my on click function, but this is obviously not working:</p>

<pre><code>var topBar = setInterval(function(){ topBarBackground() }, 1000);

function topBarBackground() {
  for (var i = 1; i &lt;= 9; i++) {
    $('.top-barz').css('background-color', 'rgba(36,36,36,.' + i + ')');
  }
}

clearInterval(topBar);
</code></pre>