$('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;
}
});
Run Code Online (Sandbox Code Playgroud)
我希望上面的代码在有人开始输入标签输入时立即触发fadeIn.有人能告诉我这样做的正确方法还是指向正确的方向?提前致谢
编辑
这是执行此操作的代码:
$('input#tags').keypress(function() {
$('#formcont').fadeIn('slow');
$('#next').hide('slow');
});
Run Code Online (Sandbox Code Playgroud)
我发现的唯一问题是我的光标不再显示在文本框中.我究竟做错了什么?
听起来像褪色正在移动你的焦点,因此光标不再存在.试试这个
$('input#tags').keypress(function() {
$('#formcont').fadeIn('slow');
$('#next').hide('slow');
$(this).focus();
});
Run Code Online (Sandbox Code Playgroud)