title: Add 1 to variable if opacity is == 1 within a setInterval
body: <p>I have a variable that I need to add 1 to each time an elements <code>opacity</code> is <code>1</code>. I need to keep checking the opacity so I have wrapped it in a <code>setInterval</code>. </p>
  
  <p>I am wondering if there is a way to only add 1 to the variable each time the opacity changes to 1 instead of keep adding 1 over and over again because of the interval. Here is my code </p>
  
  <pre class="lang-js prettyprint-override"><code>var number = 1;
  
  var intervalsizer = setInterval(function() {
    if ($(".cardButtons__discuss").css('opacity') == 1) {
      number++;
      console.log(number)
    }
  
    function fooo() {
      if (number == 1) {
        //do something
      }
      if (number == 2) {
      }
      if (number == 3) {
        //do something
      }
      if (number == 4) {
        //do something
      }
    }
  }, 50);
  </code></pre>
  
  <p>Thanks in advance </p>