【发布时间】:2018-10-25 12:52:02
【问题描述】:
在处理不同类型的“input”标签时,什么时候使用“value”属性,根据“input”的类型,它应该接收什么值?
【问题讨论】:
-
我们在哪里使用 value 属性?这非常依赖于语言...
-
是的,很抱歉。我在谈论HTML。我很遗憾错过指定这一点。
在处理不同类型的“input”标签时,什么时候使用“value”属性,根据“input”的类型,它应该接收什么值?
【问题讨论】:
控件的初始值。此属性是可选的,除非 type 属性的值为单选或复选框。 重新加载页面时,如果在重新加载之前更改了值,Firefox 和 IE 将忽略 HTML 源中指定的值。
更多详情,据此W3Schools documentation:
value属性对不同的输入类型有不同的使用:
注意:value 属性不能与 input 与属性 type="file" 一起使用。
【讨论】:
The initial value of the control. This attribute is optional except when the value of the type attribute is radio or checkbox. When reloading the page, Firefox and IE will ignore the value specified in the HTML source, if the value was changed before the reload.第一句话就概括了