Selecting HTML comments with jQuery
There's the jQuery comments() plugin which will do that for you. Usage:
var comments = $( "#foo" ).comments();
alert(comments.html());
This seems to do something equivalent to what you're looking for:
$(function() {
$("body").contents().filter(function(){
return this.nodeType == 8;
}).each(function(i, e){
alert(e.nodeValue);
});
});