如何在div内制作无效内容? [英] How to make inactive content inside a div?

查看:75
本文介绍了如何在div内制作无效内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用JavaScript使某些div块中的内容处于非活动状态?

How to make content in some div block inactive using JavaScript?

假设有一个带有命令启用/禁用"的按钮.还有一个带有一些文本的div块.按下启用/禁用"按钮时,是否为启用",您可以在其中使用内容,但是在禁用"时,则不能使用div块中的内容.

Let's say there is a button with command "Enable / Disable". And there is one div block with some text. When pushing button "Enable / Disable", is it is "Enable", you can work with content inside, but when "Disable", you can't work with content inside div block.

我想为了使div块中的内容处于非活动状态,我们需要在其上放置另一层内容,以防止在div块中编辑内容.

I imagine in order to make inactive content inside div block, we need to put another layer upon that will prevent from editing content on the content div block.

我对如何实现这种功能感到困惑.

I'm getting confused how to realize this kind of feature.

推荐答案

在不使用覆盖层的情况下,可以在CSS的div上使用pointer-events: none,但这在IE或Opera中不起作用.

Without using an overlay, you can use pointer-events: none on the div in CSS, but this does not work in IE or Opera.

div.disabled
{
  pointer-events: none;

  /* for "disabled" effect */
  opacity: 0.5;
  background: #CCC;
}

参考

这篇关于如何在div内制作无效内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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