title: jquery - click event on every anchor tag with individual id-based callback
body: <p>I have the following:</p>
  
  <pre><code>for(j=0; j&lt;conn_nodes.length; j++) {
      var content_all_connections = "";
      var node_id = conn_nodes[j]['conn_node_id']);
      var a_id = "#" + node_id_slice;
  
      content_all_connections = "&lt;a id=\""+node_id+"\"&gt;"+conn_nodes[j]['conn_node_label']+"&lt;\/a&gt;;             
      $('#all-connections-list').append(content_all_connections);
  
      /*$(a_id).on('click', function () {
          display_content(node_id);
      });*/
  }   
  
  $('.display').on('click', function () {
      display_content(node_id_slice);
  });
  </code></pre>
  
  <p>I create a couple of anchor tags width individual IDs. When I now try to set a click event within the for loop (within /<em>...</em>/) everything is fine - but the node_id is always wrong. <code>display_content(node_id)</code> is only switching between two node-id-based contents. Don't ask me why.</p>
  
  <p>Therefore, my plan is to put the click event handler out of the loop and access all <code>&lt;a&gt;</code> tags by class. Here is my question: How can I also access the ID of the anchor I was clicking on?</p>
  
  <p>Does anyone have an idea?</p>