title: Detect button click on form item
body: <p>I have a list of store items. Each item is showing its values as a form.</p>
  <pre><code>&lt;?php       
  if($statement-&gt;execute())
  {
      $result = $statement-&gt;fetchAll();
      $output = '';
      foreach($result as $row)
      {
          $output .= '
              &lt;div class=&quot;col-md-3&quot; style=&quot;margin-top:12px;&quot;&gt;  
              &lt;div class=&quot;item-content&quot; align=&quot;center&quot;&gt;
              &lt;div class=&quot;img-container&quot;&gt;
                  &lt;img src=&quot;../administrar/application/admin/productos/'.$row[&quot;image&quot;].'&quot; class=&quot;img-responsive&quot; /&gt;&lt;br /&gt;
                  &lt;h4 class=&quot;text-info&quot;&gt;'.$row[&quot;name&quot;].'&lt;/h4&gt;
                  &lt;h4 class=&quot;text-danger&quot;&gt;$ '.$row[&quot;price&quot;] .'&lt;/h4&gt;
                  &lt;input type=&quot;text&quot; name=&quot;quantity&quot; id=&quot;quantity' . $row[&quot;id&quot;] .'&quot; class=&quot;form-control&quot; value=&quot;1&quot; style=&quot;text-align:right;&quot;/&gt;
                  &lt;input type=&quot;hidden&quot; name=&quot;hidden_name&quot; id=&quot;name'.$row[&quot;id&quot;].'&quot; value=&quot;'.$row[&quot;name&quot;].'&quot; /&gt;
                  &lt;input type=&quot;hidden&quot; name=&quot;hidden_price&quot; id=&quot;price'.$row[&quot;id&quot;].'&quot; value=&quot;'.$row[&quot;price&quot;].'&quot; /&gt;
          
                  &lt;div class=&quot;input-group&quot;&gt;
                  &lt;span class=&quot;input-group-btn&quot;&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn btn-danger btn-number&quot; name=&quot;restar&quot;  id=&quot;'.$row[&quot;id&quot;].'&quot; &quot; &gt;
                  &lt;span class=&quot;glyphicon glyphicon-minus&quot;&gt;&lt;/span&gt;
                  &lt;/button&gt;
                  &lt;/span&gt;
                     
                  &lt;span class=&quot;input-group-btn&quot;&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn btn-success btn-number&quot; name=&quot;sumar&quot; id=&quot;sumar&quot;&quot;&gt;
                  &lt;span class=&quot;glyphicon glyphicon-plus&quot;&gt;&lt;/span&gt;
                  &lt;/button&gt;
                  &lt;/span&gt;
                  &lt;/div&gt;          
    
                  &lt;input type=&quot;button&quot; name=&quot;add_to_cart&quot; id=&quot;'.$row[&quot;id&quot;].'&quot; style=&quot;margin-top:5px;&quot; class=&quot;btn btn-success form-control add_to_cart&quot; value=&quot;Add to Cart&quot; /&gt;
                   &lt;/div&gt;
                   &lt;/div&gt;
               &lt;/div&gt;
          ';
      }
  }
  ?&gt;
  </code></pre>
  <p>I need to identify when the user clicks on button 'restar' from a certain form item.</p>
  <p>This is my current script, but it doesn't launch the expected alert.</p>
  <pre class="lang-js prettyprint-override"><code>&lt;script type=&quot;text/javascript&quot;&gt;
      $(document).ready(function(){
          var product_id = $(this).attr(&quot;id&quot;);
          $('#restar'+'product_id+').on('click', function(event) {
              alert(&quot;ssssspp2&quot;);
          });
      });
  &lt;/script&gt;
  </code></pre>