element.next().focus()
won't work if elements are like:
<input name="first" /><br />
<input name="second" /><br />
<input name="third" /><br />
But will if they're like
<input name="first" />
<input name="second" />
<input name="third" />
How do I solve this problem?
element.next()
returns the next DOM sibling, not the next form element. That means that if you have <br>
next to your <input>
element, it will return <br>
where .focus()
makes no sense.
Thats all.
Use this css
input{
position:relative;
display: flex;
justify-content: center;
align-items: center;
margin-bottom:10px;
}
to vertically set one by one without <br>
tag then use .next().focus()
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.