How do I put focus on a textbox with JavaScript(Or jQuery)?
I have a textbox on a page and after the user presses the enter key, the textbox loses focus. (Keep in mind that no post occurs, the page does not refresh)
I want to be able set the focus back inside of the textbox through javascript so that the user can continue typing and doesn't have to click on anything.
I tried adding the following code after the users has pressed the enter key:
$(".focus").focus(); The code for my textbox:
<input type="text" class="focus" /> but alas, the cursor does not appear inside of the textbox and the user still has to click to continue typing.
How do I fix this problem?