标签输入或标签 select,如果输入或 select 嵌套在 div 中,则焦点不起作用
label input or label select, focus not working if input or select nested in a div
试图将焦点放在样式化的 select 和嵌套在 div 中的其他输入:
<label for="focusedSelect">I want to Focus on You</label>
<div class="styled-select">
<select id="focusedSelect">
<option value="1">Won</option>
<option value="2">Too</option>
</select>
</div>
<label for="focusedInput>Let me Focus on You Too</label>
<div class="styled-inputs">
<input id="focusedInput" type="text"/>
</div>
单击标签不会为输入或嵌套 div 的 select 提供焦点。
你的代码对我来说工作正常,我只需要修正一些错误:
<label for="focusedSelect">I want to Focus on You</label>
<div class=" styled-select">
<select id="focusedSelect">
<option value="1 ">Won</option>
<option value="2 ">Too</option>
</select>
</div>
<label for="focusedInput">Let me Focus on You Too</label>
<div class="styled-inputs">
<input id="focusedInput" type="text" />
</div>
对于第二个输入,您缺少两个标签 "for" 属性的结尾引号以及结尾 <label>
元素的结尾大于号 (>) 字符。
试图将焦点放在样式化的 select 和嵌套在 div 中的其他输入:
<label for="focusedSelect">I want to Focus on You</label>
<div class="styled-select">
<select id="focusedSelect">
<option value="1">Won</option>
<option value="2">Too</option>
</select>
</div>
<label for="focusedInput>Let me Focus on You Too</label>
<div class="styled-inputs">
<input id="focusedInput" type="text"/>
</div>
单击标签不会为输入或嵌套 div 的 select 提供焦点。
你的代码对我来说工作正常,我只需要修正一些错误:
<label for="focusedSelect">I want to Focus on You</label>
<div class=" styled-select">
<select id="focusedSelect">
<option value="1 ">Won</option>
<option value="2 ">Too</option>
</select>
</div>
<label for="focusedInput">Let me Focus on You Too</label>
<div class="styled-inputs">
<input id="focusedInput" type="text" />
</div>
对于第二个输入,您缺少两个标签 "for" 属性的结尾引号以及结尾 <label>
元素的结尾大于号 (>) 字符。