// This will disable just the div
$("#dcacl").attr('disabled','disabled');
或
// 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);
或
// This will disable everything contained in the div
$("#dcacl").children().prop('disabled',true);
或
// disable ALL descendants of the DIV
$("#dcacl *").prop('disabled',true);
Javascript:
// This will disable just the div
document.getElementById("dcalc").disabled = true;
或
// 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;
}
$("#dcac1").find(":input").prop("disabled",true);
// noting that ":input" gives you the equivalent of
$("#dcac1").find("input,select,textarea,button").prop("disabled",true);
要重新启用,只需将"disabled“设置为false即可。
我想在加载页面时禁用它们,然后单击即可启用它们
好的,将上面的代码放在一个文档就绪的处理程序中,并设置一个适当的单击处理程序:
$(document).ready(function() {
var $dcac1kids = $("#dcac1").find(":input");
$dcac1kids.prop("disabled",true);