为什么输入元素“值"属性有时不会出现在 HTML 中? [英] Why input elements "value" attributes are sometimes not presented in the HTML?

查看:30
本文介绍了为什么输入元素“值"属性有时不会出现在 HTML 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时 input 元素会在视觉上显示它们的值,但是这些值不会显示在元素 HTML 中.不是文本"而不是作为价值"属性.喜欢这里
实际上,它是一个 value 属性,但它是隐藏的.
我的意思是即使 value 属性本身的存在也是隐藏的.
我想了解为什么那些 value 属性是隐藏的?

Sometimes input elements are visually presenting their values however these values are not presented in the element HTML. Not as "text" and not as "value" attributes. Like here
Actually, it's a value attribute, but it is hidden.
I mean even existence of value attribute itself is hidden.
I'd like to understand why those value attributes are hidden ?

推荐答案

对于文本类型的输入元素(以及其他一些),在原生 HTML 中,元素的 value 属性显示其默认值价值.
用户插入的文本值不会显示在那里,因此只有默认值将始终显示在 value 属性中.
如果没有为该元素设置默认值,value 属性将不会出现在元素 HTML 中.
与所附屏幕截图中的内容类似.

In case of text type input elements (and some others as well), in native HTML value attribute of the element presents its default value.
The text value inserted by the user is not presented there, so only the default value will always presented in value attribute.
In case no default value is set for that element, the value attribute will not be presented in the element HTML.
Similarly to the presented in the attached screenshot.

这篇关于为什么输入元素“值"属性有时不会出现在 HTML 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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