Posted By

Meander365 on 09/29/10


Tagged

javascript hide jquery hidden


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bobbym245


Jquery Hide an Element Right Away


 / Published in: jQuery
 

Handy. Hide an element as soon as possible, before document.ready. The element gets hidden but only when a class is applied to the html via js.

  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <script type="text/javascript" src="../assets/js/jquery.js"></script>
  6.  
  7. <script type="text/javascript">
  8.  
  9. $(function () {
  10. $('html').addClass('no-message');
  11. });
  12. </script>
  13. </head>
  14. <body>
  15. <style type="text/css">
  16. html.no-message .box {display:none;}
  17. </style>
  18. <p>In other news...</p>
  19. <div class="box"><p>I shoud be hidden!</p></div>
  20. </body>
  21. </html>

Report this snippet  

You need to login to post a comment.