什么值检查和选择是错误的? [英] What values for checked and selected are false?

查看:85
本文介绍了什么值检查和选择是错误的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为根据W3规范,你应该这样做:

 < input type =checkboxchecked = checked/> 



  selected =selected

但是,大多数浏览器都会接受它,您只需写入CHECKED 并且不要给它一个价值。那么,如果你确实包含了这个属性,那么有没有什么值会被一致地认为是错误的? 没有值,这会导致取消选中该复选框。如果选中属性存在,那么无论您将其设置为什么值,都会检查该复选框。

输入类型=复选框选中=/><输入类型= checkboxchecked =checked/>< input type =checkboxchecked =unchecked/>< input type =checkboxchecked =true/>< input type =checkbox checked =false/>< input type =checkboxchecked =on/>< input type =checkboxchecked =off/>< input type =checkboxchecked =1/>< input type =checkboxchecked =0/>< input type =checkboxchecked =yes/>< input type =checkbox no/>< input type =checkboxchecked =y/>< input type =checkboxchecked =n/>  



呈现ev在所有现代浏览器(FF3.6,Chrome 10,IE8)中都检查过。


I think according to W3 spec, you're supposed to do

<input type="checkbox" checked="checked" />

And

 selected="selected"

But, most browsers will accept it you just write "CHECKED" and don't give it a value. So, what if you do include the attribute, are there any values that would be (consistently) considered false?

解决方案

There are no values that will cause the checkbox to be unchecked. If the checked attribute exists, the checkbox will be checked regardless of what value you set it to.

<input type="checkbox" checked />
<input type="checkbox" checked="" />
<input type="checkbox" checked="checked" />
<input type="checkbox" checked="unchecked" />
<input type="checkbox" checked="true" />
<input type="checkbox" checked="false" />
<input type="checkbox" checked="on" />
<input type="checkbox" checked="off" />
<input type="checkbox" checked="1" />
<input type="checkbox" checked="0" />
<input type="checkbox" checked="yes" />
<input type="checkbox" checked="no" />
<input type="checkbox" checked="y" />
<input type="checkbox" checked="n" />

Renders everything checked in all modern browsers (FF3.6, Chrome 10, IE8).

这篇关于什么值检查和选择是错误的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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