Selecting HTML comments with jQuery

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);
        });
    });

Leave a Comment