点击标签未打开 select

click on label doesn't open select

我一直认为,单击 label 或多或少会 "trigger" 单击相应的表单元素。 然而,当涉及到 select 时,这似乎不起作用。 "mousedown-on-selectfield"-动画有效,但 select 未打开。

我试过这个:

<label for="my_id">Click me</label>
<select id="my_id">
  <option>1</option>
  <option>2</option>
</select>

还有那个:

<label for="my_id">Click me
  <select id="my_id">
    <option>1</option>
    <option>2</option>
  </select>
</label>

知道我做错了什么吗?

PS:我认为这里不需要任何 Javascript,因为这是一个 html-feature

根据 W3C,点击标签可能不会执行任何操作或将 onFocus 事件发送到相关字段。在这种情况下,通常它会在 select 元素上触发 onFocus。

https://www.w3.org/TR/html5/forms.html#the-label-element