title: Get Key From a Button ID That is an Array When Clicked With jQuery
body: <p>Hi I'm a bit new to jQuery. I'm trying to get the key value from a button id which is an array when clicked as shown below:</p>
  <pre><code>&lt;button id=&quot;button[1]&quot;&gt;Submit&lt;/button&gt;
  &lt;button id=&quot;button[2]&quot;&gt;Submit&lt;/button&gt;
  &lt;button id=&quot;button[3]&quot;&gt;Submit&lt;/button&gt;
  &lt;button id=&quot;button[4]&quot;&gt;Submit&lt;/button&gt;
  </code></pre>
  <p>The expected result is when clicked is 1 or 2 or etc.</p>
  <p>In PHP I would achieve this by getting the name which is an array also as shown below:</p>
  <pre><code>&lt;html&gt;
      &lt;button name=&quot;button[1]&quot;&gt;Submit&lt;/button&gt;
      &lt;button name=&quot;button[2]&quot;&gt;Submit&lt;/button&gt;
      &lt;button name=&quot;button[3]&quot;&gt;Submit&lt;/button&gt;
      &lt;button name=&quot;button[4]&quot;&gt;Submit&lt;/button&gt;
  &lt;/html&gt;
  &lt;?php
      key($_POST['button']);
  ?&gt;
  </code></pre>
  <p>How would I achieve this using jQuery?</p>