Hide multiple elements at once - Javascript DOM

Javascript examples for DOM:Document querySelectorAll

Description

Hide multiple elements at once

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  w  ww .  j  a  v  a2 s. co  m*/
var elems = document.querySelectorAll('p,li');
for(var i = 0;i < elems.length; i++)
{
    elems[i].style.display = 'none';
}
    }

      </script> 
   </head> 
   <body> 
      <p>1</p> 
      <ul> 
         <li>2</li> 
      </ul>  
   </body>
</html>

Related Tutorials