1

我的页面中有不止一个fieldset。每个都有几个textfield

我想关注任何选定textfield的 . 我怎样才能做到这一点?

假设我有这样的

<fieldset>
<legend>First Page</legend>
<input id="bp1" name="bp1" type="text" AUTOCOMPLETE=OFF />
<input id="bp2" name="bp2" type="text" AUTOCOMPLETE=OFF />
<input id="bp3" name="bp3" type="text" AUTOCOMPLETE=OFF />
</fieldset>

<fieldset>
<legend> Next Page</legend>
<input id="other1" name="other1" type="text" AUTOCOMPLETE=OFF />
<input id="other2" name="other2" type="text" AUTOCOMPLETE=OFF />
<input id="other3" name="other3" type="text" AUTOCOMPLETE=OFF />

</fieldset>
<div id="navigation" style="display:none;">
                    <ul>
                        <li class="selected">
                            <a href="#">First Page</a>
                        </li>
                        <li>
                            <a href="#">Next Page</a>
                        </li>

我想在第一页关注我的第三个文本字段(id="bp3"),在下一页我想关注第二个文本字段,即 id="other3"。这个怎么做?

4

1 回答 1

0

在您想要关注的字段上使用focus()

document.getElementById('bp3').focus()

然后在下一页visibility事件上,即点击下一页

<a href="#" onclick="document.getElementById('other3').focus()">Next Page</a>

于 2013-11-13T12:42:30.810 回答