开发者

Label for File input in 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 l开发者_如何学Pythonabel gets ignored. Is this a bug? A "feature"? And is there any way to still accomplish this?

jsFiddle testcase: here


The label's prescribed behavior differs between HTML specifications.

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.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜