名称的 HTML 标签 [英] HTML label for name

查看:18
本文介绍了名称的 HTML 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以对元素 name 使用标签 for 属性而不是 id?我们的应用程序存在错误,其中两个复选框具有相同的 ID,单击一个的标签会检查另一个.由于丑陋和复杂的html生成逻辑,更改id会很痛苦.

Is it possible to use label for attribute for element name instead of id? Our application has bug where two checkbox has the same id, and clicking label for one checks the another. It would be pain to change the id due the ugly and complicated html generation logic.

然而,两个复选框都有唯一的名称属性,使用标签 for 这个名称将是一个快速的解决方案.这可能吗?

However, both checkbox has unique name-attribute, and it would be quick solution to use label for this name. Is this possible?

推荐答案

是否可以将标签用于元素名称而不是 id 的属性?

Is it possible to use label for attribute for element name instead of id?

没有

HTML 将其定义为与 ID 相关,仅与 ID 相关,仅与 ID 相关.

HTML defines it as relating to the ID, only the ID, and nothing but the ID.

这篇关于名称的 HTML 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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