jquery检查某人何时开始输入某个字段

$('a#next').click(function() { var tags = $('input[name=tags]'); if(tags.val()==''){ tags.addClass('hightlight'); return false; }else{ tags.removeClass('hightlight'); $('#formcont').fadeIn('slow'); $('#next').hide('slow'); return false; } }); 

我希望上面的代码在有人开始输入标签输入时立即触发fadeIn。 有人能告诉我这样做的正确方法还是指向正确的方向? 提前致谢

编辑

这是执行此操作的代码:

 $('input#tags').keypress(function() { $('#formcont').fadeIn('slow'); $('#next').hide('slow'); }); 

我发现的唯一问题是我的光标不再显示在文本框中。 我究竟做错了什么?

听起来像褪色正在移动你的焦点,因此光标不再存在。 试试这个

 $('input#tags').keypress(function() { $('#formcont').fadeIn('slow'); $('#next').hide('slow'); $(this).focus(); }); 

你想要焦点事件 。

  $('a#next').focus(function() { $('#formcont').fadeIn('slow'); }); 

input#tags是多余的,浪费。

 $('#tags').keypress(function() { $('#formcont').fadeIn('slow'); $('#next').hide('slow'); $(this).focus(); });