HTML5 - 输入=数字和不兼容的浏览器 [英] HTML5 - input=number and incompatible browsers

查看:113
本文介绍了HTML5 - 输入=数字和不兼容的浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站上使用html5元素< input type =number> ,但我想知道浏览器中的这个字段会发生什么不支持此功能?它不是经典的< input type =text> 这些浏览器的字段吗?

解决方案

当浏览器无法识别< input> 的特定类型 ,它会恢复为默认值,即 text 。因此,以下所有内容在不支持 type =number:

的浏览器上相同 >

 < input type =number> 
< input type =somevaluethatdoesntexist>
< input type =text>
<输入>

对于 do 支持 type =将会显示数字数字 <输入> >,而不是 text < input>



a href =http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#attr-input-type> type HTML规范中的code>属性。


I want to use the html5 element <input type="number"> on my website, but i want to know what happens to this field in browsers that do not support this feature? Is it than a classic <input type="text"> field for those browsers?

解决方案

When a browser does not recognize a particular type value for an <input>, it reverts to it's default value, which is text. So, all of the following are equivalent on browsers that do not support type="number":

<input type="number">
<input type="somevaluethatdoesntexist">
<input type="text">
<input>

For browsers that do support type="number", the number <input> will be displayed instead of the text <input>.

Read more about the type attribute in the HTML Specification.

这篇关于HTML5 - 输入=数字和不兼容的浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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