Best way to implement jQuery click functions
<p>I have some HTML code that is created dynamically and includes potentially dozens of anchors.  I want to add a click handler to each anchor and I can think of a number of different ways but don't know which one to choose.  Assuming the anchors have a class of "myclass" and the code executed when clicked is the same for each.</p>

<p><strong>Method 1</strong></p>

<pre><code>$(document).delegate(".myclass", "click", function() {
  // Do some work
});
</code></pre>

<p><strong>Method 2:</strong></p>

<pre><code>var $a = $("&lt;a href='#' class='myclass'&gt;Text&lt;/a&gt;");
$a.bind("click", function() {
  // Do some work
});
</code></pre>

<p><strong>Method 3:</strong></p>

<pre><code>function clickHandler() {
  // Do some work
}

var $a = $("&lt;a href='#' class='myclass'&gt;Text&lt;/a&gt;");
$a.bind("click", function() {
  clickHandler();
});
</code></pre>

<p>I like Method 2 as the handler code is right where the anchor is created and added to the DOM but if I have lots of these anchors then will JavaScript effectively create dozens of separate functions or is it clever enough to use just one?</p>
