Created
June 19, 2014 18:24
-
-
Save jonathanstark/22ee69e86b0f9177fd2f to your computer and use it in GitHub Desktop.
Uncomment HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* I didn't write this snippet but I can't remeber where I found it. PLMK if you know who the original author is :) */ | |
(function($) { | |
$.fn.uncomment = function(recurse) { | |
$(this).contents().each(function() { | |
if (this.hasChildNodes()) { | |
$(this).uncomment(recurse); | |
} else if (this.nodeType == 8) { | |
// Need to "evaluate" the HTML content, | |
// otherwise simple text won't replace | |
var e = $('<span>' + this.nodeValue + '</span>'); | |
$(this).replaceWith(e.contents()); | |
} | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment