Adding jQuery event handlers to elements with wildcard IDs
<p>I currently have the following in a document.ready block:</p>

<pre><code>        $("[id^=summaryDetailLink_]").each(function(index) {
        var splitID = this.id.split("_");
        this.click(alert('clicked: '+splitID[1])); //toggleDetail(splitID[1])
    });
</code></pre>

<p>Ultimately I want to detect when a TD with an ID of "summaryDetail_" is clicked on and fire the toggleDetail function with the ID taken from the TD.ID attribute.</p>

<p>The above seems to generate the correct ID (the alert popsup) but is firing when the page loads rather than when I click on the element.</p>

<p>So problem number 1 - why is it firing on page load rather than creating a handler for click on each element and waiting for that click?</p>

<p>Problem number 2, in reading around this issue it seems it would be more sensible to create a single event handler on the table rather the TD then determine which TD element was clicked. How would I convert the code to do that?</p>
