if/else doesn't work

if/else doesn't work

hello,

I have a jquery script. The meaning is, when you have 4 divs in the browser then the first div hide.
You must only see 3 divs and not more.
I have written but it doesn't work.
Can someone help me?

thanks in advance.


  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  5. <script>
  6. $(document).ready(function(){
  7.     if($( "div" ).html() == 4; ))
  8.     {
  9.       $( "div:first").hide();
  10.      }

  11. });
  12. </script>
  13. </head>
  14. <body>



  15. <div><p>This is a paragraph with little content.</p></div>//this div is not hide.
  16. <div><p>This is another small paragraph.</p></div>
  17. <div><p>This is a test</p></div>
  18. <div><p>fourth div </p></div>

  19. </body>
  20. </html>