gpt4 book ai didi

javascript - 禁用除 DIV 元素之外的所有元素

转载 作者:搜寻专家 更新时间:2023-11-01 05:05:20 25 4
gpt4 key购买 nike

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

最佳答案

我为你做了一个简单的例子,

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

关于javascript - 禁用除 DIV 元素之外的所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22249885/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com