How to do when loading a page put focus on an input and cursor stay after value that is inside the input?

Asked

Viewed 34 times

0

When loading a page I am focusing on an input, but it puts the cursor always to the extreme left, like to put the focus and the cursor was after the text inside the input and not before as you are doing

I managed to get him to focus on the input but he puts the focus before the text that comes along with input

<script>
document.nomeformulario.nomecampo.focus();
</script>
<form name='nomeformulario' action='pagina' method='POST'>
<input name='nomecampo' type='text' value'5'>
<button type='submit'>enviar</button>
</form>

in the code I typed it puts the focus on the input and the cursor before the 5 would like you to put the focus on the input and the cursor after the 5

The left what happens To right what I want Saida Real: Saida Esperada:

  • The "example 1" of Caique Romero’s answer should suit you well. ;)

  • Thanks for the help

  • You’re welcome! Good luck!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.