Skip to content

Instantly share code, notes, and snippets.

@simonw
Created February 25, 2009 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonw/70248 to your computer and use it in GitHub Desktop.
Save simonw/70248 to your computer and use it in GitHub Desktop.
jQuery methods for accessing HTML comments and comment text. Only tested in Safari.
/* jQuery methods for accessing HTML comments and comment text
Only tested in Safari. */
jQuery.fn.comments = function() {
return this.contents().filter(function() {
return this.nodeType == 8;
})
};
jQuery.fn.commentText = function() {
var s = [];
this.comments().each(function() {
s[s.length] = this.nodeValue;
});
return s.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment