知识点:jquery two

.ticket { display: none; }

$(‘.confirmation’).on(‘click’, ‘button’, function(){ $(this).closest(‘.confirmation’).find(‘.ticket’).slideDown(); });

.slideDown() .slideUp() .slideToggle()

jqurey 使用alert debug

$(document).ready(function(){ alert($(‘img’).length); });

$(document).ready(function(){ $(‘.confirmation’).on(‘click’,’button’, function(){ $(this).closest(‘.confirmation’).find(‘.ticket’).sildeDown(); }); $(‘.confirmation’).on(‘mouseenter’,’h3’, function(){ $(this).closest(‘.confirmation’).find(‘.ticket’).sildeDown(); }); });

$(document).ready(function(){ function showTicket(){ $(this).closest(‘.confirmation’).find(‘.ticket’).sildeDown(); } $(‘.confirmation’).on(‘click’,’button’,showTicket); $(‘.confirmation’).on(‘mouseenter’,’h3’,showTicket); });

$(document).ready(function() { $(.vacation).on(‘keyup’, ‘quantity’, function(){ var price = +$(this).closest(‘.vacation’).data(‘price’); var quantity = +$(this).val(); $(‘.total’).text(price * quantity); }); });

$(document).ready(function() { $(‘#nights’).on(‘keyup’, function() { var price = +$(this).closest(‘.tour’).data(‘daily-price’); var nights = +$(this).val(); $(‘#total’).text(nights * price); $(‘#nights-count’).text($(this).val());

}); });

$(document).ready(function() { $(‘#nights’).on(‘keyup’, function() { var nights = +$(this).val(); var dailyPrice = +$(this).closest(“.tour”).data(“daily-price”); $(‘#total’).text(nights * dailyPrice); $(‘#nights-count’).text($(this).val()); }); $(‘#nights’).on(‘focus’, function() { $(‘#nights’).val(7); }); });

$(document).ready(function(){ $(‘.vacation’).on(click, ‘.expand’, function(event){ event.preventDefault(); $(this).closest(‘.vacation’).find(‘.comments’).fadeToggle(); }); });

$(document).ready(function() { $(‘.see-photos’).on(‘click’, function(event) { event.stopPropagation(); event.preventDefault(); $(this).closest(‘.tour’).find(‘.photos’).slideToggle(); }); $(‘.tour’).on(‘click’, function() { alert(‘This event handler should not be called.’); }); });