Premium headphone
26 |├── README.md ├── cart.js ├── hw8.html └── style.css /README.md: -------------------------------------------------------------------------------- 1 | # hw8 2 | 3 | ![This is an image] 4 | -------------------------------------------------------------------------------- /cart.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | var cartCountValue = 0; 3 | var cartCount = $('.count'); 4 | $(cartCount).text(cartCountValue); 5 | 6 | $('.cart-btn').on('click', function(){ 7 | var cartBtn = this; 8 | var cartCountPosition = $(cartCount).offset(); 9 | var btnPosition = $(this).offset(); 10 | var leftPos = 11 | cartCountPosition.left < btnPosition.left 12 | ? btnPosition.left - (btnPosition.left - cartCountPosition.left) 13 | : cartCountPosition.left; 14 | 15 | var topPos = 16 | cartCountPosition.top < btnPosition.top 17 | ? cartCountPosition.top 18 | : cartCountPosition.top; 19 | $(cartBtn) 20 | .append("1"); 21 | 22 | $(cartBtn).find('.count').each(function(i, count){ 23 | $(count).offset({ 24 | left: leftPos, 25 | top: topPos 26 | }) 27 | .animate( 28 | { 29 | opcity: 0 30 | }, 31 | 800, 32 | function(){ 33 | $(this).remove(); 34 | cartCountValue++; 35 | $(cartCount).text(cartCountValue); 36 | $(cartCount).text(cartCountValue); 37 | } 38 | ); 39 | }); 40 | }); 41 | }); -------------------------------------------------------------------------------- /hw8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |Premium headphone
26 |Premium black airpod
42 |Premium digital watch
58 |