This question already has an answer here:
- How to disable all div content 24 answers
I am looking for a method to Enable and Disable the div id="dcalc" and Its children.
<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;
If you want to disable all the div's controls, you can try adding a transparent div on the div to disable, you gonna make it unclickable, also use fadeTo to create a disable appearance.
try this.
The following selects all descendant elements and disables them:
But it only really makes sense to disable certain element types: inputs, buttons, etc., so you want a more specific selector:
To re-enable you just set "disabled" to false.
OK, so put the above code in a document ready handler, and setup an appropriate click handler:
I've cached the results of the selector on the assumption that you're not adding more elements to the div between the page load and the click. And I've attached the click handler with
.one()
since you haven't specified a requirement to re-disable the elements so presumably the event only needs to be handled once. Of course you can change the.one()
to.click()
if appropriate.You should be able to set these via the
attr()
orprop()
functions in jQuery as shown below:jQuery (< 1.7):
or
jQuery (>= 1.7):
or
or
Javascript:
or