如何禁用< div>法案? [英] How should disabled <div> act?

查看:107
本文介绍了如何禁用< div>法案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 $(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>.

Fiddle

<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.

这篇关于如何禁用&lt; div&gt;法案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆