Maxew's picture
cree un site de vente de cookier
84b2f10 verified
Raw History Blame Contribute Delete
1.91 kB
document.addEventListener('DOMContentLoaded', function() {
// Add to cart functionality
const addToCartButtons = document.querySelectorAll('button:contains("Add to Cart")');
addToCartButtons.forEach(button => {
button.addEventListener('click', function() {
const productName = this.closest('.bg-white').querySelector('h3').textContent;
const productPrice = this.closest('.bg-white').querySelector('span').textContent;
// Create cookie animation
const cookie = document.createElement('div');
cookie.innerHTML = '<i data-feather="cookie" class="text-cookie-500"></i>';
cookie.className = 'fixed bottom-4 right-4 text-4xl cookie-spin';
document.body.appendChild(cookie);
feather.replace();
// Show notification
const notification = document.createElement('div');
notification.className = 'fixed bottom-4 left-4 bg-white text-cookie-800 px-4 py-2 rounded-lg shadow-lg flex items-center';
notification.innerHTML = `
<i data-feather="check-circle" class="text-green-500 mr-2"></i>
Added ${productName} (${productPrice}) to cart!
`;
document.body.appendChild(notification);
feather.replace();
// Remove notification after 3 seconds
setTimeout(() => {
notification.remove();
cookie.remove();
}, 3000);
});
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
});