Hide HTML Comments - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:hide

Description

Hide HTML Comments

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.js"></script> 
  <script type="text/javascript">
    window.onload=function(){//from   ww w . ja v a2  s . com
$('*').contents().each(function() {
    if(this.nodeType === Node.COMMENT_NODE) {
        $(this).remove();
    }
});
    }

      </script> 
 </head> 
 <body> 
  <!-- comment #1 --> 
  <div class="test">
    Hello World 
   <!-- comment #2 --> 
  </div>  
 </body>
</html>

Related Tutorials