禁用除DIV元素之外的所有内容 [英] Disable everything except a DIV element

查看:108
本文介绍了禁用除DIV元素之外的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在div元素中有一个视频播放器。我想禁用除DIV之外的所有内容。一种方法是使用灯箱,但我想知道我是否可以使用纯HTML / Javascript进行。

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;}

检查 FIDDLE

这篇关于禁用除DIV元素之外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆