Refer to the first child element.firstElementChild.nextElementSibling - Javascript DOM

Javascript examples for DOM:Element nextElementSibling

Description

Refer to the first child element.firstElementChild.nextElementSibling

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from  ww  w .j a va  2 s.  c om*/
var test1 = document.getElementById("test1").firstElementChild.nextElementSibling;
while (test1) {
    test1.style.display = "none";
    test1 = test1.nextElementSibling;
}
    }

      </script> 
   </head> 
   <body> 
      <div id="test1"> 
         <p>Lorem ipsum</p> 
         <p>Lorem ipsum</p> 
         <p>Lorem ipsum</p> 
      </div>  
   </body>
</html>

Related Tutorials