-5

There is a Video player under the div that has myDiv class. I want to hide the whole web site and just wanted to display the Video i.e myDiv and it's children.How to do it using either jQuery or JavaScript.

<body>
   <header></header>
   <main>
      <section></section>
      <section>
        <div class="myDiv">
           <div></div>
           <div</div>
        </div>
      </section>
      <section></section>
   </main>
   <footer></footer>
</body>
kiran goud
  • 803
  • 2
  • 10
  • 17

2 Answers2

0

Try with filter() function of jquery

$('section').filter(function(){
 return $(this).find('.myDiv').length == 0 //its hiding except myDiv
}).hide()
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<body>
  <main>
    <section>first</section>
    <section>second contains myDiv
      <div class="myDiv">its a my div
        <div>i m child of myDiv</div>
        <div>i m child of myDiv</div>
      </div>
    </section>
    <section>Third</section>
  </main>
</body>
prasanth
  • 22,145
  • 4
  • 29
  • 53
0

you can give the video div a class and every other div a hide class and write code so that when you click on it to play, it hides everything else.

so in your jquery

$('.videoClass').click(function(){
 $('.hide').css('display','none');
});

and you can add a toggle so when you click it again, it shows all hidden divs.