I have a textbox in my html body: input type="text" id="text-input"
I am using this to bring it into focus when the user presses enter:
<script>
$(document).keypress(function(e) {
if(e.keyCode == 13) {
$("#text-input").focus();
}
});
</script>
The webpage I am using to try it out has only the text box in it. When I click on a blank area, and press enter, the "|" prompt will be misaligned downwards. If I repeat this clicking and pressing enter, the "|", which is supposed to be in the textbox, keeps moving down more and more.
What went wrong?