I got:
$(someTextInputField).keypress(function() {
alert($(this).val());
});
Now the alert always returns the value BEFORE the keypress
(e.g. the field is empty, I type 'a' and the alert gives me ''. Then I type 'b' and the alert gives me 'a'...). But I want the value AFTER the keypress
- how can I do that?
背景:只要文本字段包含至少一个字符,我就希望启用按钮.因此,我对每个keypress
个事件运行此测试,但是使用返回的val()
,结果总是落后一步.我不能 Select 使用change()
事件,因为这样直到您离开文本框该按钮才会被禁用.如果有更好的办法,我很高兴听到!