访问隐藏的输入元素
问题描述:
答
你必须在你的标签页流中有一个支持tabindex
的项目,并且你的单选按钮是隐藏的,不起作用。该锚标记不支持标签指数然而,这样你就可以用a
标签包装每个贵丽标签的内部元件,并指定在您的流动工作的tabindex属性...
变化:
<li tabindex="0" class="radio gchoice_2_14_0">
<input style="margin-left:1px;" name="input_14" type="radio" value="2017/2018" id="choice_2_14_0" onclick="gf_apply_rules(2,[0]);" onkeypress="gf_apply_rules(2,[0]);">
<label tabindex="0" for="choice_2_14_0" id="label_2_14_0">2017/2018
</label>
</li>
要:
<li tabindex="0" class="radio gchoice_2_14_0">
<a tabindex="1010">
<input style="margin-left:1px;" name="input_14" type="radio" value="2017/2018" id="choice_2_14_0" onclick="gf_apply_rules(2,[0]);" onkeypress="gf_apply_rules(2,[0]);">
<label tabindex="0" for="choice_2_14_0" id="label_2_14_0">2017/2018
</label>
</a>
</li>
这将给锚标记焦点,当你标签给它(屁股如果前一个元素的tabindex是'1009'或更低)。
这回答你的问题如何选项卡。现在你已经有了,你需要做一些事情:
- 如果你认为合适的话,给元素的css指定
form li.radio a:focus
。 - 为
a
元素设置按键事件,以便您在聚焦时可以使用Enter键按下来真正选择您的假单选按钮。
'a'可能没有'input' /'label'后代。 – unor
感谢罗伯特明确指出隐藏的元素无法通过选项卡进行访问。因此我将tabindex添加到父元素并使用了一些javascript。 –