[This documentation is preliminary and is subject to change.]
Sets or retrieves a value that indicates whether the user can interact with the object.
Syntax
| HTML | <element disabled="p" ... > |
|---|---|
| JavaScript | |
Property values
Type: Boolean
Remarks
When an element is disabled, it appears dimmed and does not respond to user input. Disabled elements do not respond to mouse events, nor will they respond to the contentEditable property.
If an element's disabled property is set to false but it is contained within a disabled element, it cannot override the disabled state of its container.
For link, style and styleSheet, the attribute sets or retrieves whether a style sheet is applied to the object.
Note For OPTGROUP and OPTION, the functionality specified by the HTML 4.01 standard is not currently implemented. You can define your own functionality.
Examples
This example uses the disabled property to enable or disable a style object and a control.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/disabled.htm
<style type="text/css" id="oStyle">
.styletest {
background-color: black;
color: white;
}
.styletest2 {
background-color: black;
color: red;
}
</style>
<script type="text/javascript">
function fnSwitch(){
if(oTest.enablement=="enabled"){
// Use an arbitrary attribute to track the status.
oTest.enablement="disabled";
oButton.value="Set disabled to false";
oStyle.disabled=true;
oDisableMe.disabled=true;
}
else{
oButton.value="Set disabled to true";
oTest.enablement="enabled";
oStyle.disabled=false;
oDisableMe.disabled=false;
}
}
</script>
...
<p enablement="enabled" id="oTest" class="styletest">
A paragraph of text.
<input type="button" id="oDisableMe" class="styletest" value="Demonstration Button" onclick="alert('Demonstration button')">
</p>
<input type="button" id="oButton" value="Set disabled to true" onclick="fnSwitch()">
See also
- button
- input type=button
- input type=checkbox
- input type=file
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- select
- textArea
- link
- style
- styleSheet
- optGroup
- option
- disabled
Build date: 3/8/2012