javascripthtmlshadowbox

Disable everything except a DIV element


I have a video player in a div element. I want to disable everything except the DIV. One way to do it is using lightbox, but I was wondering if I could do it using plain HTML/Javascript.


Solution

  • I did simple example for you,

    jQuery ;

            $(".disable").on('click', function(){
               // * = select All, find Div, Not (#video) and edit css opacity
                $("*").find('div').not("#video").css('opacity', '0.1');
    
            });
    

    HTML ;

       <button class="disable">Disable</button>    
        <div class="header">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum     has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
    
    <div id="video">
       <img src="http://fandomania.com/wp-content/uploads/2012/04/06/anarchy01.jpg">
     </div>
    
    <div class="footer">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    

    Css ;

    .header{border:1px solid #000;background:#cc0000;color:#fff;}
    .footer{border:1px solid #000;background:#cc0000;color:#fff;}
    

    Check FIDDLE