Javascript examples for DOM HTML Element:Div
Only display the first child of a div
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w ww . j a va 2 s. co m*/ 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>