假设我有
<input id="a" />
<a href="foo">foo</a>
<input id="b" />
默认情况下,选项卡会将我从a
tofoo
带到b
。如果我想直接从a
到b
我可以这样做
document .getElementById ("a") .setAttribute ("tabindex", 1);
document .getElementById ("b") .setAttribute ("tabindex", 2);
但是现在以下内容不起作用,因为focus()
显然需要tabindex=-1
document .getElementById ("b") .focus ();
我可以两者兼得吗?