问题描述
HTML表单上的名称
属性的要点是什么?据我所知,你不能在提交时阅读表单名称或做任何事情。它有什么作用?
What's the point of the name
attribute on an HTML form? As far as I can tell, you can't read the form name on submission or do anything else with it. Does it serve a purpose?
推荐答案
简而言之,可能过于简单化了一点:它被用来代替 id
用于不理解 document.getElementById
。
In short, and probably oversimplifying a bit: It is used instead of id
for browsers that don't understand document.getElementById
.
的浏览器这些天它没有真正的目的。在使用 name
来描述如何在提交表单时如何发送控制值以及 id之前,这是浏览器大战早期的遗留问题
识别页面内的元素已经结算。
These days it serves no real purpose. It is a legacy from the early days of the browser wars before the use of name
to describe how to send control values when a form is submitted and id
to identify an element within the page was settled.
这篇关于HTML表单的`name`属性有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!