如何禁用< div>法案? [英] How should disabled <div> act?
问题描述
当我使用 $(selector).children()。attr(disabled,disabled)时,注意到以下错误:
code>< div> 。
< div disabled =disabled>
< input type =textvalue =RAGE/>
< / div> FF b / b
$ b $ p
基本测试说FF4 / Chrome启用该字段。 IE9禁用该字段。
预期的行为是什么?
与其他非表单元素相同(< input>
,< select> ;
等)
解决方案 < div>
元素根据HTML规范没有禁用
属性。预期的行为是阻止您的标记正确验证。
但是,新的HTML5规范允许< fieldset>
有一个禁用
属性,它禁用任何嵌套的输入字段。但是,它并没有得到广泛的支持,所以你将无法依靠这个功能一段时间。
I noticed the following bug when using $(selector).children().attr("disabled", "disabled")
where the children happened to contain a <div>
.
<div disabled="disabled">
<input type="text" value="RAGE" />
</div>
Basic testing says FF4/Chrome enable the field. IE9 disables the field.
What is the expected behaviour?
Same for any other non form element (<input>
, <select>
, etc)
解决方案 <div>
elements do not have a disabled
attribute according to the HTML specification. The expected behavior is to prevent your markup from validating correctly.
However, the new HTML5 specification allows for <fieldset>
to have a disabled
attribute, which disables any nested input fields. It's not widely supported yet though, so you won't be able to rely on this feature for a while.
这篇关于如何禁用< div>法案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!