I am wondering how I can hide all divs on the page only using Javascript, I cannot use Jquery. Is there a way to do this without using the arrays that comes with document.getElementByTag? Or if there is not, could you show me how to hide all? Thanks!

Recommended Answers

All 4 Replies

Hi there,

You can use jQuery if you want some cool effects. have a look at jQuery

in pure javascript, you'd need something like the below code. This does what you want using ElementById. It is not gonna be hard then to work out what you exactly want to do.

 <script type="text/javascript">
    function hideMe()
    {
          document.getElementById('myDiv').style.display="hidden"   ;
    }
 </script>


   <body>

       <div id="myDiv"  onclick="return hideMe();">
               Hide me.
       </div>

   </body>

I hope this helps.

Member Avatar for iamthwee

I cannot use Jquery

Seriously... Why?

It's not by any choice of mine! The Studio that we use is written strangely, and I have not yet been able to implement JQuery on it. If I could/knew how to, believe me I'd be all over it!

Member Avatar for iamthwee

OK in that case I can't help. Good luck though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.