Is it possible to get a reference to a live collection in jQuery?
<p>I have a simple table with 1 row to start out with. </p>

<pre><code>&lt;table&gt;
    &lt;tr id="tr1"&gt;
        &lt;td&gt;ROW 1&lt;/td&gt;
        &lt;td&gt;ROW 1&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>Each <code>tr</code> listens to a click event. Once clicked on a table row I would like to get the number of rows in the table without having to constantly requery it. Does jQuery somewhere store the current collection of <code>tr's</code> and if so how can I access it?</p>

<pre><code>$("table").on("click", "tr", function(e){

    $("#output").html("click on row with id " + $(this).attr("id") + "&lt;br&gt;")

        $("#output").append("Number of rows" + $("table").find("tr").size())
        // instead of "live" requerying $("table").find("tr") is there another way to get to all tr's

});

// more code...

$("table").append("&lt;tr id='tr2'&gt;&lt;td&gt;ROW 2&lt;/td&gt;&lt;td&gt;ROW 2&lt;/td&gt;&lt;/tr&gt;");
</code></pre>

<p>EDIT: To be clear, getting the number of rows is just an example. I actually need to perform other operations on the collection as well</p>

<p>See example here: <a href="http://jsfiddle.net/Flandre/Ed4pp/2/" rel="nofollow">http://jsfiddle.net/Flandre/Ed4pp/2/</a></p>
