html – 使用标签标签提交表单

html – 使用标签标签提交表单,第1张

概述在不使用图像或 javascript的情况下很难设置提交输入. 据我所知,没有办法将HTML代码直接插入到sumbit输入值中.如果我将提交输入包装在div元素中(例如添加多个边框),则不是整个区域都是可点击的. 点击标签会导致在所有浏览器中提交表单吗? <form method="test.rb"> <input type="text" name="test" id="test" /> <l 在不使用图像或 javascript的情况下很难设置提交输入.

据我所知,没有办法将HTML代码直接插入到sumbit输入值中.如果我将提交输入包装在div元素中(例如添加多个边框),则不是整个区域都是可点击的.

点击标签会导致在所有浏览器中提交表单吗?

<form method="test.rb"> <input type="text" name="test" ID="test" /> <label for="button">  <input type="submit" name="button" ID="button" value="Send!" /> </label></form>
解决方法 根据 the W3C on associating labels:

The label element is not used for the following because labels for these elements are provIDed via the value attribute (for submit and reset buttons),the alt attribute (for image buttons),or element content itself (button).

感谢@Jeremiah Isaacson指出这一点.

老答案

是的,这会奏效.我无法验证所有浏览器的行为,但这里是W3C spec has to say:

To associate a label with another
control implicitly,the control
element must be within the contents of
the LABEL element … When a LABEL
element receives focus,it passes the
focus on to its associated control.

所以,我想通过单击LABEL,您基本上是单击提交输入.

感谢@stevelove指出了这个的可行性.

总结

以上是内存溢出为你收集整理的html – 使用标签标签提交表单全部内容,希望文章能够帮你解决html – 使用标签标签提交表单所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1069419.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存