我正在寻找一种方法来解决这个问题

<div id="dcalc" class="nerkheArz"
 style="left: 50px; top: 150px; width: 380px; height: 370px;
 background: #CDF; text-align: center" >
 <div class="nerkh-Arz"></div>
 <div id="calc"> </div>
</div>

I want to Disable them at loading the page and then by a click i can enable them ?

This is what i have tried

document.getElementById("dcalc").disabled = true;

推荐答案

您应该能够通过jQuery中的attr()prop()函数设置这些,如下所示:

jQuery (< 1.7):

// This will disable just the div
$("#dcacl").attr('disabled','disabled');

or个个

// This will disable everything contained in the div
$("#dcacl").children().attr("disabled","disabled");

jQuery (>= 1.7):

// This will disable just the div
$("#dcacl").prop('disabled',true);

or个个

// This will disable everything contained in the div
$("#dcacl").children().prop('disabled',true);

or个个

//  disable ALL descendants of the DIV
$("#dcacl *").prop('disabled',true);

Javascript:

// This will disable just the div
document.getElementById("dcalc").disabled = true;

or个个

// This will disable all the children of the div
var nodes = document.getElementById("dcalc").getElementsByTagName('*');
for(var i = 0; i < nodes.length; i++){
     nodes[i].disabled = true;
}

Jquery相关问答推荐

当我使用 OwlCarousel 时,没有任何显示

如何在 jquery 中切换 attr()

jquery如何判断ajax调用的响应类型

如果您的 Select 器对象无效,为什么 jQuery 不会炸弹?

如何从 jQuery 转到 React.js?

jQuery:使用变量作为 Select 器

$.post 和 $.ajax 之间的区别?

jQuery 与 ExtJS

我们如何在不重新加载页面的情况下使用 javascript/jQuery 更新 URL 或查询字符串?

jQuery: Select 属性大于值的所有元素

动画元素变换旋转

为什么使用 jQuery on() 而不是 click()

使用 jQuery DataTables 时禁用第一列的自动排序

使用 AJAX 加载 Bootstrap 弹出内容.这可能吗?

我可以通过 JavaScript 禁用 CSS :hover 效果吗?

使用 JQuery 的黄色淡入淡出效果

$.ajax 的成功和 .done() 方法有什么区别

为什么要使用发布/订阅模式(在 JS/jQuery 中)?

.animate() 的回调被调用两次 jquery

jquery $(window).height() 正在返回文档高度