Yadhu Phinix
Yadhu Phinix

Reputation: 57

Perfom action of "tab" key onkeyup()

I have 4 text fields. When i enter a value in first text box cursor should move to next text box. That is onkeyup() i need to perform action of tab key. Is there any javascript or jquery for that

Upvotes: 0

Views: 149

Answers (1)

mry
mry

Reputation: 314

You can try this

HTML

<input type="text" class="focus" />
<input type="text" class="focus" />
<input type="text" class="focus" />
<input type="text" class="focus" />

JS

  $(".focus").keyup(function(){
   if($(this).val() != "")
   {
    $(this).next(".focus").focus();
   }
  });

Upvotes: 1

Related Questions