title: jQuery: add click event to specific id
body: <p>I have a small jquery problem:</p>
  
  <p>My code is like this:</p>
  
  <pre><code>&lt;div id="select-word-5" class="select-word-link"&gt; - some content - &lt;/div&gt;
  &lt;div id="select-5" class="select"&gt; - some content - &lt;/div&gt;
  </code></pre>
  
  <p>I have throughout my document several select-word-link and select divs.</p>
  
  <p>I want to add a click event to the first div, that reacts just to the second div.</p>
  
  <p>My idea was to loop through all the "select-x" elements, but i think there is a much better way?</p>
  
  <pre><code>$('.select-word-link').each(function()
  {
  
      var id = this.id;
      var idLink = this.id.replace("-word", "");
  
  
      $('.select').each(function()
      {
  
          if (idLink == this.id)
          {
  
  
            $(id).click(function() {
              alert("this does not work");
  
          });
  
      });
  
  
  });
  </code></pre>