title: How can I call a dynamic id?
body: <p>My code is like this :</p>
  
  <pre><code>&lt;?php
      for($i=0;$i&lt;5; $i++) {
  
  ?&gt;
          &lt;button type="submit" id="test&lt;?php echo $i ?&gt;"&gt;
              test &lt;?php echo $i ?&gt;
          &lt;/button&gt;
  &lt;?php
      }
  ?&gt;
  &lt;script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      for(var i=0; i &lt; 5; i++) {        
          $("#test"+i).click(function(){
              console.log('test'+i);
          });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>When I click button anything, the result : </p>
  
  <blockquote>
    <p>test5</p>
  </blockquote>
  
  <p>Should when I click button test 0, the result : test0</p>
  
  <p>Why it does not work?</p>