title: How to increment counter and decrement it with Jquery
body: <p>Hi guys I need assistance with incrementing a variable with just one value for a user and when the user clicks the same button the value decreases by one and this cycles continues. There is a situation similar in the 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-js lang-js prettyprint-override"><code>$(function() {
    var indicator = 0;
    $('#btn1').on('click', function() {
      $('#toggleIndicator').show();
      indicator++;
      alert('ON value : ' + indicator);
    })
  
    $('#btn2').on('click', function() {
      $('#toggleIndicator').hide();
      indicator--;
      alert('OFF value : ' + indicator);
    })
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>div {
    width: 100px;
    height: 20px;
    margin-bottom: 10px;
  }
  .a {
    background-color: orange;
  }
  .b {
    background-color: gold;
  }
  .c {
    background-color: maroon;
  }
  .d {
    background-color: green;
  }</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="a" id="toggleIndicator"&gt;
  &lt;/div&gt;
  
  &lt;input type="button" id="btn1" value="ON" /&gt;
  &lt;input type="button" id="btn2" value="OFF" /&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>but in my case I want the actions to be on one button just like on or off. Any way to do this please?</p>