checked attribute | checked property
Sets or retrieves the state of the check box or radio button.
![]() |
Syntax
| HTML | <element checked="p" ... > |
|---|---|
| JavaScript | |
Property values
Type: Boolean
Standards information
- Document Object Model (DOM) Level 1 Specification, Section 2.5.5
- HTML 4.01 Specification, Section 17.4
Remarks
Check boxes that are not selected do not return their values when the form is submitted.
A user can select a radio button only if the button has a name. To clear a selected radio button, a user must select another button in the set.
Windows Internet Explorer 8 and later. In IE8 Standards mode, parsing operations on the checked content attribute always affect both the checked content attribute and defaultChecked Document Object Model (DOM) attribute. For example, removeAttribute('checked') sets both checked and defaultChecked to false. Similarly, setAttribute('checked', 'checked') sets both DOM attributes to true (as if the element was being re-parsed) For more information on IE8 mode, see Defining Document Compatibility.
Internet Explorer 8 and later. In IE8 mode, the defaultChecked DOM attribute reflects the value of the checked content attribute.
Examples
This example retrieves the checked property to fire an event.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/checked.htm
<head>
<script type="text/javascript">
function checkthis()
{
if (oCheckbox.checked == true)
{
window.open("http://www.microsoft.com");
}
}
</script>
</head>
<body>
<p>Check here if you wish to go to Microsoft:
<input id="oCheckbox" type="checkbox" onclick="checkthis()"></p>
</body>
See also
- input
- input type=checkbox
- input type=radio
- Reference
- defaultChecked
- Conceptual
- Introduction to Forms
- Form controls part 1
- Form controls part 2: validation
