I am creating a simple todolist function. I have a textfield like so:
<input type="text" class="textbox">
on blur take value and append to:
<div class="outerbox"></div>
as:
<div class="box">value from textbox</div>
This is done in jQuery, now after this event I want to move the cursor back into the .textbox (on blur).
How can this be done ?
I tried $(‘.textbox’).focus(); which did’nt work..
Full code:
$(".textbox").blur(function(){
// 1. values
val = $(this).val();
time = '';
// 2. append
$(".outline").append('<div class="box"><div class="time">'+time+'</div>'+val+"</div>");
// 3. focus
setTimeout(function(){$('.textbox').focus();},0);
});
You probably need to break the callstack since you are trying to set focus on an element from inside it’s blur event handler.
try to use
it should do the trick for you