HTML中id和name属性的区别

Difference between id and name attributes in HTML(HTML中id和name属性的区别)
本文介绍了HTML中id和name属性的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

idname 属性有什么区别?它们似乎都具有提供标识符的相同目的.

What is the difference between the id and name attributes? They both seem to serve the same purpose of providing an identifier.

我想知道(特别是关于 HTML 表单)是否有必要或出于任何原因鼓励使用两者.

I would like to know (specifically with regards to HTML forms) whether or not using both is necessary or encouraged for any reasons.

推荐答案

name 属性在表单提交中发送数据时使用.不同的控件响应不同.例如,您可能有几个具有不同 id 属性但 name 相同的单选按钮.提交后,响应中只有一个值 - 您选择的单选按钮.

The name attribute is used when sending data in a form submission. Different controls respond differently. For example, you may have several radio buttons with different id attributes, but the same name. When submitted, there is just the one value in the response - the radio button you selected.

当然,它的意义远不止这些,但它肯定会让你朝着正确的方向思考.

Of course, there's more to it than that, but it will definitely get you thinking in the right direction.

这篇关于HTML中id和name属性的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Select OK button from N#39;th modal opened in testcafe(从 testcafe 中打开的第 N 个模式中选择 OK 按钮)
How to click a specified li for an autocomplete ul with Selenium IDE?(如何使用 Selenium IDE 为自动完成 ul 单击指定的 li?)
Test automation html element selectors. Element ID or DataAttribute(测试自动化 html 元素选择器.元素 ID 或 DataAttribute)
@JdbcInsert insert multiple entries(@JdbcInsert 插入多个条目)
How can I make Geolocation API function working on localhost file://?(如何使 Geolocation API 函数在 localhost file://上工作?)
navigator.geolocation.getCurrentPosition not allowed on quot;file:///C:/quot; based access(“file:///C:/上不允许 navigator.geolocation.getCurrentPosition基于访问)