title: Binding function to multiple elements with Jquery
body: <p>I have this small problem with jquery: I need to do something like this:</p>
  
  <pre><code>$(document).ready(function(){
      links = {};
      links.a = "Link a";
      links.b = "Link b";
      links.c = "Link c";
  
      for (x in links){
          $("#" + x).css("border","1px solid #000");
          $("#" + x).click(function(){
              alert(x);
          });
      }
  });
  &lt;/script&gt;
  &lt;div id="a"&gt;a&lt;/div&gt;&lt;br /&gt;
  &lt;div id="b"&gt;b&lt;/div&gt;&lt;br /&gt;
  &lt;div id="c"&gt;c&lt;/div&gt;&lt;br /&gt;
  </code></pre>
  
  <p>So that when you click on div#a you will get "Link a" alert, "Link b" on div#b and so on...
  The problem is that if you run this code, clicking on each element will give alert("Link c") as result, it seems that only the last function variation is assigned to each div...</p>
  
  <p>Of course i can hack it by editing the function to work with div's id and using $(this), but for cursiosity: is there a way to make this cycle work? By creating and assigning a new function to each element in function?</p>
  
  <p>Thx in advance...</p>