It looks like you're trying to make objects with .class
disappear. Use .hide()
instead. Comments are only parsed when the browser first loads the page, so adding comments won't comment something out.
You need to learn the difference between HTML and the DOM. HTML is the textual representation of the page, but the browser parses it into the DOM on page load. JavaScript works on the DOM, not on the HTML. Using .innerHtml()
on DOM elements reparses the HTML.
Here's an example of using innerHtml()
to hide elements using HTML comments (but note that I would never do this - I'm only showing how to do what it looked like you were trying to do in your question):
HTML:
<h1>hello</h1>
<div>
<p>wow</p>
<p>dude</p>
</div>
JavaScript (+ jQuery):
$(document).ready(function () {
setTimeout(hideIt, 1000);
});
function hideIt() {
$('div').html('<!--' + $('div').html() + '-->');
}