I have more than one fieldset
in my page. Each has few number of textfield
in it.
I want to focus any selected textfield
. How can i do this?
suppose if i have like this
<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>
I want to focus on my 3rd textfield(id="bp3") in first page and in the next page i want to focus to 2nd textfield ie id="other3". How to do this?
use focus() on the field you want to focus like
document.getElementById('bp3').focus()
then on next page visibility
event ie onclick of next page
<a href="#" onclick="document.getElementById('other3').focus()">Next Page</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.