Помогите пожалуйста !
Ндо сделать так чтобы по нажатии клвиши enter происходил переход между полями inpyt
<!DOCTYPE html> <html> <body> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> </body> </html> |
Цитата:
|
переход по enter или tab зацикленно
Лунтик,
<!DOCTYPE html> <html> <meta charset="utf-8"> <body> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <p><input maxlength="200" size="5" id="user" ></p> <script> const inps = document.querySelectorAll('[id="user"]'); inps.forEach((input, i) => { const next = inps[++i % inps.length]; input.addEventListener('keydown', event => { if(event.code == 'Enter' || event.code == 'Tab') (event.preventDefault(), next.select(), next.focus()) }); }) </script> </body> </html> |
А можно сделать так чтобы НИ сверху в низ а наоборот снизу в верх
|
Цитата:
const next = inps[(inps.length + --i) % inps.length]; |
Спасибо бальшое
|
Часовой пояс GMT +3, время: 06:21. |