uncomment is a jQuery plugin that will allow you "move" commented HTML code into the DOM
The main reason I've made this plugin is to allow some content to be displayed
only to javascript-enabled clients, without relying the display: none;
CSS
(which some text browsers don't take into account)
This could be used as an opposite of the <noscript>
tag
Simple example:
<p id="uncomment">
The <!-- <em>quick</em> brown -->
fox jumps over the <!-- lazy --> dog <br />
<a href="#">Click here to reveal <!-- hidden --> comments</a>
</p>
<script type="text/javascript">
$('#uncomment a:last').click(function(e) {
e.preventDefault();
$('#uncomment').uncomment(/* recurse */ true );
});
</script>
The
fox jumps over the dog
Click here to reveal comments
A more practical example:
<noscript>
I will only be shown when javascript is disabled
</noscript>
<div class="scriptonly"><!--
I will only be shown then javascript is enabled
--></div>
<script type="text/javascript">
$(document).ready(function() {
/* The recurse argument is false by default.
* - when recurse is false, uncomment will only look for
comments in the specified selector.
* - when recurse is true, it will look in its children too
*/
$('.scriptonly').uncomment( true )
});
</script>