title: Passing in parameter from html element with jQuery
body: <p>I'm working with jQuery for the first time and need some help. I have html that looks like the following:</p>
  
  <pre><code>&lt;div id='comment-8' class='comment'&gt;
      &lt;p&gt;Blah blah&lt;/p&gt;
      &lt;div class='tools'&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div id='comment-9' class='comment'&gt;
      &lt;p&gt;Blah blah something else&lt;/p&gt;
      &lt;div class='tools'&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm trying to use jQuery to add spans to the .tools divs that call variouis functions when clicked. The functions needs to receive the id (either the entire 'comment-8' or just the '8' part) of the parent comment so I can then show a form or other information about the comment.</p>
  
  <p>What I have thus far is:</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
  
      $(function() {
          var actionSpan = $('&lt;span&gt;[Do Something]&lt;/span&gt;');
          actionSpan.bind('click', doSomething);
  
          $('.tools').append(actionSpan);
       });
  
       function doSomething(commentId) { alert(commentId); }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I'm stuck on how to populate the commentId parameter for doSomething. Perhaps instead of the id, I should be passing in a reference to the span that was clicked. That would probably be fine as well, but I'm unsure of how to accomplish that.</p>
  
  <p>Thanks,
  Brian</p>