Q: Are `jQuery.find` results "live"?
What made me think they might be?
by dimadima
HTML
<p id="question">Q: Are `jQuery.find` results "live"?</p>
<p id="answer">A: </p>
JavaScript
console.clear();
var html = $('<h1>What hurts?</h1>' +
'<p>Choose where your pain is most concentrated:</p>' +
'<ul class="body-parts"></ul>' +
'<div class="hero-nav"></div>')
, cont = $('<div></div>')
, late = function() { return cont.find('.hero-nav') }
, early = cont.filter('.hero-nav');
console.log("Before insert, late bound: " + late().length);
console.log("Before insert, early bound: " + early.length);
cont.append(html);
console.log("After insert, late bound: " + late().length);
console.log("After insert, early bound: " + early.length);
$('#answer').text($('#answer').text() + ((late().length == early.length) ? 'Yes' : 'No'));