title: How to pass text from view to javascript
body: <p>Hi there i have problem with <code>Rails</code> &amp; <code>Javascript</code>. Here is my table in view.</p>
  
  <pre><code>&lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;No&lt;/th&gt;
        &lt;th&gt;Name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr id="adminrow"&gt;
          &lt;td&gt;
            1
          &lt;/td&gt;
          &lt;td&gt;
            &lt;a href="#" id="select_name"&gt;John&lt;/a&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr id="adminrow"&gt;
          &lt;td&gt;
            2
          &lt;/td&gt;
          &lt;td&gt;
            &lt;a href="#" id="select_name"&gt;Alex&lt;/a&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr id="adminrow"&gt;
          &lt;td&gt;
            3
          &lt;/td&gt;
          &lt;td&gt;
            &lt;a href="#" id="select_name"&gt;Paul&lt;/a&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>and my <code>JS</code> is</p>
  
  <pre><code>$('#select_name').click(function(event){
      var username = $("#select_name").text();
      console.log(username);
  });
  </code></pre>
  
  <p>I have lot of names in my table, but <code>JS</code> printed first name in console. How can I print each name in the table to console?</p>