jQuery Script Tag Handling
Passing script tags into jQuery's constructor as html text causes them to be removed from the result.
by kaen
JavaScript
var sourceText = '<script class="bad" type="text/javascript">document.writeln("boo...");<\/script>'
sourceText += '<script class="good" type="text/javascript">document.writeln("yea!");<\/script>';
// this would print both messages to the document
// $(document).append(sourceText);
// but if we make our own jQuery object and try to query against it...
$tree = $(sourceText);
// jQuery yields an empty array, and the script is never executed
document.writeln($tree.find('.good').length);
document.writeln('<br />');
// however, the scripts are still actually in the jQuery object we created
document.writeln($tree.length);
// console.dir($tree);