HTML元素与[id]具有相同的[名称]可以吗? [英] Is it ok for an HTML element to have the same [name] as its [id]?

查看:159
本文介绍了HTML元素与[id]具有相同的[名称]可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < object type =我正在使用Satay方法在网页中嵌入Flash应用程序。 application / x-shockwave-flashdata =embeddy.swf
id =embeddyname =embeddy>
< param name =movievalue =embeddy.swf/>
< / object>

我想要提供正确的 objectID ExternalInterface.objectID ,这意味着我需要设置名称 id 属性。



通常我会尽量避免命名冲突在HTML中有元素,但是在这种情况下将两个属性设置为相同的值有什么问题吗?



HTML表单是什么?有没有人觉得值得设置(n)( input | select | textarea )元素的名称 id 属性为相同的值?

解决方案

您可以使用ID进行JavaScript操作。

/ p>

这两个是没有关系的。所以设置为相同的值是好的,但不是必需的。


I'm working on embedding a flash app in a webpage using the Satay method:

<object type="application/x-shockwave-flash" data="embeddy.swf"
id="embeddy" name="embeddy">
  <param name="movie" value="embeddy.swf" />
</object>

I want flash to provide the correct objectID in ExternalInterface.objectID, which means I need to set both the name and id attributes for the object.

Normally I try to avoid naming collisions with elements in HTML, but is there anything wrong with setting both attributes to the same value in this case?

What about HTML forms? Does anyone feel that it's worthwhile to set a(n) ( input | select | textarea ) element's name and id attributes to the same value?

解决方案

You use IDs for JavaScript manipulation.

You use Names for form field submission.

The two are not related. So setting both to the same value is OK, but it is not required.

这篇关于HTML元素与[id]具有相同的[名称]可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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