The problem is that the change event fires only when focus is moved away from the input (eg someone clicks off the input or tabs out of it).(问题在于,仅当焦点从输入移开时,更改事件才会触发(例如,有人单击了输入或将选项卡移出了输入)。)
Try using keyup instead:(尝试改用keyup:)
$(document).ready(function() {
$(':input[type="submit"]').prop('disabled', true);
$('input[type="text"]').keyup(function() {
if($(this).val() != '') {
$(':input[type="submit"]').prop('disabled', false);
}
});
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…