Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

javascript - 如何禁用所有div内容(How to disable all div content)

I was under the assumption that if I disabled a div, all content got disabled too.(我假设如果我禁用了div,所有内容也被禁用了。)

However, the content is grayed but I can still interact with it.(但是,内容是灰色的,但我仍然可以与之交互。)

Is there a way to do that?(有没有办法做到这一点?)

(disable a div and get all content disabled also)((禁用div并禁用所有内容))   ask by juan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.(禁用任何DIV(包括其内容)的简单方法是禁用鼠标交互。) For example:(例如:)
$("#mydiv").addClass("disabledbutton");

css(CSS)

.disabledbutton {
    pointer-events: none;
    opacity: 0.4;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...