I'm using jQuery focus to set focus on a newly created input.
It works well, but the focus is set in the beginning of the input even though there is a pre-defined text. How can I place it after the text?
$('.button').on('click', function () {
$('.container').html('<input type="text" class="newinput" value="word">');
$('.newinput').focus();
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="button">create and focus</button>
<br />
<div class="container"></div>