我有以下代码:
$(document).ready(function () {
var selectedDay = '#selected_day';
$(function () {
$("#date").datepicker({
dateFormat: "DD, d M yy",
altField: selectedDay,
altFormat: "DD",
onSelect: function () {
$(selectedDay).change()
}
});
$('#selected_day, #times, #name, #group_number, #e-mail, #phone, #additional_info').change(function () {
if ($(selectedDay).val() == '') {
$('#times').fadeOut(500);
} else {
$('#times').fadeIn(500);
}
if ($(selectedDay).val() == 'Friday' || $(selectedDay).val() == 'Saturday') {
$('#times').find('option[value="6pm"], option[value="8pm"], option[value="10pm"], option[value="11pm"]').hide();
} else {
$('#times').find('option[value="6pm"], option[value="8pm"], option[value="10pm"], option[value="11pm"]').show();
}
$('#confirm').text('You have chosen ' + $('#date').val() + ' at ' + $('#times').val() + '. This will be booked under the name of ' + $('#name').val() + ' for ' + $('#group_number').val() + ' people. We will contact you on either your phone number (' + $('#phone').val() + ') or your e-mail address (' + $('#e-mail').val() + ') to confirm your booking with us. Thank you for choosing Buddha Belly');
});
$('#phone').on('keypress', function () {
$('#confirm').fadeIn(500);
});
});
});
在底部你会注意到我希望在手机输入栏中按下键时确认div会淡入。然而,这不会发生,我必须键入内容然后单击文档中的其他位置。你可以放任何光吗?
答案 0 :(得分:5)