It looks like you are trying to delete objects with .class . Use .hide() . Comments are only processed if the browser first loads the page, so adding comments will not comment on anything.
You need to know the difference between HTML and DOM. HTML is a textual representation of a page, but the browser parses it in the DOM when the page loads. JavaScript works on the DOM, not HTML. Using .innerHtml() in DOM elements renders HTML.
Here is an example of using innerHtml() to hide elements using HTML comments (but note that I will never do this - I'm only showing how to do what looked like what 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() + '-->'); }
Skilldrick
source share