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.

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

How to disable all div content, Many of the above answers only work on form elements. A simple way to disable any DIV including its contents is to just disable mouse interaction. For example: If you have a div, and you want to support click or a key event on that div, then you have to do two things: 1) When you want to disable the div, set its disabled attribute as usual (just to comply with the convention) 2) In your div’s click and/or key handlers, check if disabled attribute is set on the div.

To do this really thoroughly cross-browser, you need an iframe, which you can create dynamically. Give the iframe a z-index higher than anything else on the page except the video div, make the iframe the full size of the viewport/page, and then make the video div a higher z-index. Now, all clicks except those on the video div go to the iframe, which presumably ignores them. You can also use opacity on the iframe if you want to "dim out" the rest of the page.

Very roughly:

function maskAllExcept(div) {
    var iframe = document.createElement('iframe');
    iframe.style.position = "absolute";
    iframe.style.left = iframe.style.right = iframe.style.top = iframe.style.bottom = "0";
    iframe.style.zIndex = 1000;
    div.style.zIndex = 1001;
    document.body.appendChild(iframe);
}

Disable all elements within <div> - JavaScript, How can I disable all form elements within <div> at once? For example: <div id ='example'> <input type=text name='ex1'> <input type=text name='ex2' > <input type=text It will work on most browsers except for IE7 Disable everything except an element and its descendants with Pure CSS. Let's do it with a common HTML dialog where this behavior could be necessary (you can use a div if you like) We just need to add a class to avoid pointer events in all the body except our dialog and its descendants.

Disable everything except an element and its descendants with Pure CSS. Let's do it with a common HTML dialog where this behavior could be necessary (you can use a div if you like)

We just need to add a class to avoid pointer events in all the body except our dialog and its descendants.

body.only-dialog *:not(dialog *) { /* not supported yet */
  pointer-events: none;
}

Because, :not only supports a single simple selector, we have to do it like this:

body.only-dialog * {
  pointer-events: none;
}

body.only-dialog dialog * {
  pointer-events: all;
}

https://jsfiddle.net/bmntvLfs/

Hope this help to future generations :)

jQuery :not() Selector, The :not() selector selects all elements except the specified element. This is mostly used together with another selector to select everything except the specified� Would ` all = el.getElementsByTagName('*') ` work if I have more than one type of form element in the list? and will this work on all browsers? It will work on most browsers except for IE7

this may help you

<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>
            <div id="popup" class="popup">

                <div id="large_map_canvas"  style="width:550px; height:550px;" align="right"><iframe align="center" src="your url for video"  style="width:545px; height:523px; overflow:hidden;"></iframe></div>
            </div>
                <a href="javascript:void(0)" onclick="showPopup();">Click to view larger map </a>
        </td>
    </tr>
</table>

<div id="mainDiv" class="businessDetail-backStyle" style="display:none;"> </div>


<script type="text/javascript"> 

    function showPopup() {
        document.getElementById('popup').style.display = 'block';
        document.getElementById('mainDiv').style.display = 'block';
    }

    function hidePopup(){
        document.getElementById('popup').style.display = 'none';
        document.getElementById('mainDiv').style.display = 'none';
    }

</script>

<style type="text/css">
  .popup {

    position:absolute;
    top:0%;
    left:37%;
    margin:-50px 0 0 -100px; 
    padding:11px;
    display:none;
    background:#FFF;
    z-index:9999;
  }

  .businessDetail-backStyle
  {
background-color:  #333333;
opacity: 90%;
filter:alpha(opacity=90);
background-color: rgba(0,0,0,0.737);
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
color: white;
z-index:999;

}

    </style>

HTML disabled Attribute, Then, a JavaScript could remove the disabled value, and make the element usable. Applies to. The disabled attribute can be used on the following elements: � (disable a div and get all content disabled also) How to disable the contents of a DIV The CSS pointer-events property alone doesn't disable child elements from scrolling, and it's not supported by IE10 and under for DIV elements (only for SVG).

How to Disable All Input Controls Inside a Form Using jQuery, You can use the jQuery prop() method in combination with the :input selector to disable all <input> , <textarea> , <select> and <button> elements inside an� Now you can’t interact with this element, or any children of this element, with a mouse, or on a touch device. But you can still tab to it with your keyboard. Mathias Bynens suggested to use the attribute tabindex=”-1” on the disabled element to completely disable it. But unfortunately, this doesn’t seem to work: while you can’t tab

How to disable all DIV content after clicking a button using , Assuming you meant how to disable all such elements inside a div tag. Let the html be: <div id="myDiv">. <input� Books. Learning jQuery Fourth Edition Karl Swedberg and Jonathan Chaffer jQuery in Action Bear Bibeault, Yehuda Katz, and Aurelio De Rosa jQuery Succinctly Cody Lindley

How to disable all html form elements within a DIV tag using JQuery , Answer: To disable all input elements within div use the following code: $('# message :input').attr('disabled',� div { opacity: 1.0; } div:hover { opacity: 0.5; } But what if we want to have that hover state apply to everything but the element actually being hovered over? (e.g. other adjacent sibling divs)

Comments
  • You might wanna show us some code here?
  • Errrrrmmmmm, what exactly do you want to do here??
  • Create masked div, place it a z-index over 9000 et voila
  • you can use css class for that
  • just to note this doesn't work for the general case: you end up setting opacity:0.1 for ancestors of #video