Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger an event after hitting Tab key in textbox

Tags:

jquery

tabs

I want to trigger an event like displaying an alert message when I hit the Tab key inside a textbox.

<input type="text" />

$("input").blur(function (e) {
   if (e.which == 9)
       alert("Hurray!!!");
});

What I want to happen is that whenever I type inside a textbox then hit Tab it will do something.

Im using jquery1.7.2.min.js

I really don't know if Im doing it right.

For the demo http://jsfiddle.net/QfCpC/

like image 547
TheOnlyIdiot Avatar asked Nov 29 '22 01:11

TheOnlyIdiot


2 Answers

$("input").keydown(function (e) {

   if (e.which == 9)
       alert("Hurray!!!");
});

Fiddle Demo

like image 72
Raab Avatar answered Dec 05 '22 03:12

Raab


Will this help

$("input").live("keydown" , function (e) {
if (e.which == 9)
   alert("Hurray!!!");
});

http://jsfiddle.net/QfCpC/3/

like image 44
Moons Avatar answered Dec 05 '22 03:12

Moons