www.fgks.org   »   [go: up one dir, main page]

DISABLED Attribute | disabled Property

Sets or retrieves a value that indicates whether the user can interact with the object.

Syntax

HTML<ELEMENT DISABLED ... >
Scripting[ bDisabled = ] object.disabled

Possible Values

bDisabledBoolean that specifies or receives one of the following values.
falseDefault. Element is not disabled.
trueElement is disabled.

The property is read/write. The property has a default value of false.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

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.0 World Wide Web link standard is not currently implemented. You can define your own functionality.

Example

This example uses the disabled property to enable or disable a style object and a control.

<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" >
     </p>
     <input type="button" id="oButton" value="Set disabled to true" >
This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

This property is defined in HTML 4.0 World Wide Web link and is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 World Wide Web link.

Applies To

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

See Also

disabled


MSDN Library
Web Development
HTML and CSS
HTML and DHTML Reference
Properties
disabled (BUTTON, INPUT, SELECT, TEXTAREA)