当用户单击某个字段时,此代码可以正常工作。我想要它,以便当它们选项卡(按下alt键)或任意键时......无论发生什么,如果此字段处于活动状态,请运行此jQuery代码。到目前为止我只知道.click()
jQuery(document).ready(function(){
$("#fullname").click(function(){
$("#note_email").fadeIn();
});
});
<input type="text" name="fullname" id="fullname" value="" /><div style="display:none" id="note_email">Your name is case sensitive</div>
答案 0 :(得分:4)
尝试使用jQuery.bind()并绑定应执行此代码的所有事件。
$("#fullname").bind('click keypress keyup change focus', function(){
$("#note_email").fadeIn();
});
但在我看来,焦点会处理你想要的东西
$("#fullname").bind('focus', function(){
$("#note_email").fadeIn();
});
OR
$("#fullname").focus(function(){
$("#note_email").fadeIn();
});