您能检查用户是否在编辑文本字段而没有编辑任何内容吗?我希望当用户在文本字段中按下回车键时调用一个函数。我知道使用表单可以实现该功能。
咖啡:
$(document).keyup (e) ->
func() if e.which is 13 and "user is in input field"
Javascript:
$(document).keyup(function(e) {
if(e.which == 13 and "user is in input field") {
func();
}
});