title: How to get the index of a list of buttons in jquery
body: <p>I have a couple of buttons</p>
  
  <pre><code>&lt;button id="btn-ok[1]" class="btn-ok"&gt;&lt;/button&gt;
  &lt;button id="btn-failed[1]" class="btn-failed"&gt;&lt;/button&gt;
  
  &lt;button id="btn-ok[2]" class="btn-ok"&gt;&lt;/button&gt;
  &lt;button id="btn-failed[2]" class="btn-failed"&gt;&lt;/button&gt;
  
  &lt;button id="btn-ok[3]" class="btn-ok"&gt;&lt;/button&gt;
  &lt;button id="btn-failed[3]" class="btn-failed"&gt;&lt;/button&gt;
  </code></pre>
  
  <p>And I am running differnt jquery functions for btn-ok and for btn-failed.
  I would like to use the index number of the id. How can I obtain it? </p>
  
  <pre><code>&lt;script&gt;
    $(document).ready(function() {
          $('#btn-ok').click(function() {
              console.log('I would like to print the index of the pressed button here. (i.e. 1,2,3)');
          });
    });
  
  &lt;/script&gt;
  </code></pre>