Since this setting is not an attribute
(由于此设置不是属性)
It is an attribute.
(这是一个属性。)
Some attributes are defined as boolean, which means you can specify their value and leave everything else out.
(某些属性定义为boolean,这意味着您可以指定其值并将其他所有内容保留。)
ie Instead of disabled=" (disabled) ", you include only the bold part.(即,仅包括粗体部分而不是禁用=“ (禁用)
”。)
In HTML 4, you should include only the bold part as the full version is marked as a feature with limited support (although that is less true now then when the spec was written).(在HTML 4中,您应该只包含粗体部分,因为完整版本被标记为支持有限的功能 (尽管现在编写规范时不太正确)。)
As of HTML 5, the rules have changed and now you include only the name and not the value.
(从HTML 5开始,规则已经更改,现在只包含名称而不包含值。)
This makes no practical difference because the name and the value are the same.(这没有实际区别,因为名称和值是相同的。)
The DOM property is also called disabled
and is a boolean that takes true
or false
.
(DOM属性也称为disabled
,是一个带true
或false
的布尔值。)
foo.disabled = true;
In theory you can also foo.setAttribute('disabled', 'disabled');
(理论上你也可以foo.setAttribute('disabled', 'disabled');
)
and foo.removeAttribute("disabled")
, but I wouldn't trust this with older versions of Internet Explorer (which are notoriously buggy when it comes to setAttribute
).(和foo.removeAttribute("disabled")
,但我不相信旧版本的Internet Explorer(在setAttribute
是众所周知的错误)。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…