Why the expression for live needs to be evaluated in jQuery
<p>The following question is inspired by <a href="http://ajaxian.com/archives/jquery-bondage" rel="nofollow">this blog entry</a> at ajaxian.com and <a href="http://ajaxian.com/archives/jquery-bondage#comment-276284" rel="nofollow">this comment by paul irish</a>.</p>

<p>Here is a way to declare live event. </p>

<pre><code>$("li a").live(...)
</code></pre>

<p>As per <a href="http://www.neeraj.name/blog/articles/882-how-live-method-works-in-jquery-why-it-does-not-work-in-some-cases-when-to-use-livequery" rel="nofollow">this blog entry</a>, it is my understanding that live events are nothing but a catch all at the document level. Any event that bubbles all the way to the top are caught by live events and if the selector is matching then the function is invoked.</p>

<p>It is my understanding that on document ready if I invoke</p>

<pre><code>$("li a").live('click', ..)
</code></pre>

<p>then all jQuery should do is to put the literal selector 'li a' in memory somewhere. Now when a click happens and if that click bubbles all the way to the top then live should check what is the target element. If the target element satisfies the rule of 'li a' then the function should be fired otherwise ignored this bubbled up event.</p>

<p>Based on that presumption on document ready when I am calling</p>

<pre><code>$("li a").live('click', ..)
</code></pre>

<p>then ideally jQuery should not actually go looking for all the element matching 'li a' because jquery does not do anything with those elements. I know for sure that the elements that are currently present in the document matching 'li a' are not bound to any event handler. </p>

<p>If all jQuery has to do is to put the literal 'li a' at the document root level then why go looking for elements matching the criteria 'li a' on document ready. But based on the comment link that I mentioned at the top, it seems jQuery actually goes about looking for element on document ready. </p>

<p>My question is why should live method find all the 'li a' methods when it is not going to do anything with them. I guess the live syntax should have been something like</p>

<pre><code>$.live('li a', 'click', function(){})
</code></pre>

<p>Am I missing something here?</p>
