在Firefox中的文件输入标签 [英] Label for File input in firefox

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

问题描述

当我添加一个表单输入的标签时,我通常可以点击标签,它会将我引用到相应的输入(见下文)。

When I add a label the a form input, I can normally click the label and it will refer me to the appropriate input (see below).

<label for="input">Label</label><input type="text" id="input"/>

但是,当我试图用文件输入完成同样的操作时,标签上的点击被忽略。这是一个错误?一个功能?还有什么办法可以完成这个吗?

However, when I try to accomplish the same with a file input, the click on the label gets ignored. Is this a bug? A "feature"? And is there any way to still accomplish this?

jsFiddle testcase:这里

jsFiddle testcase: here

推荐答案

更确切地说,这可能是FF中的一个错误(而不是其他的一个额外的特性),因为这个行为通常应该包含在HTML 4规范中:
当LABEL元素获得焦点时,它将焦点传递给其关联的控件。举例来说,请参阅以下关于访问键的部分。

More precisely, this is probably a bug in FF (rather than an extra feature in the others), because this behavior should usually be included according to the HTML 4 spec: When a LABEL element receives focus, it passes the focus on to its associated control. See the section below on access keys for examples.

当前的HTML规范更细微,但是确实表明它什么也不做(这是iOS中的预期行为) 。

The current HTML spec is more nuanced, but does indicate the possibility that it do nothing (this is the expected behavior in iOS).

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

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