targetElement.scrollIntoView({ behavior: 'smooth' }); // 关闭移动端菜单 if (!mobileMenu.classList.contains('hidden')) { mobileMenu.classList.add('hidden'); } } }); }); // 产品卡片悬停效果 document.querySelectorAll('.product-card').forEach(card => { card.addEventListener('mouseenter', function() { this.classList.add('shadow-xl'); this.querySelector('.product-image').classList.add('scale-110'); }); card.addEventListener('mouseleave', function() { this.classList.remove('shadow-xl'); this.querySelector('.product-image').classList.remove('scale-110'); }); }); // 产品描述和规格选项卡切换 const tabs = document.querySelectorAll('.border-b-2 button'); const tabContents = document.querySelectorAll('.border-b-2 + div > div'); tabs.forEach(tab => { tab.addEventListener('click', () => { // 移除所有标签的活动状态 tabs.forEach(t => { t.classList.remove('text-hermes', 'border-hermes'); t.classList.add('text-gray-500', 'hover:text-gray-700'); }); // 为当前点击的标签添加活动状态 tab.classList.remove('text-gray-500', 'hover:text-gray-700'); tab.classList.add('text-hermes', 'border-b-2', 'border-hermes'); // 隐藏所有内容 tabContents.forEach(content => { content.style.display = 'none'; }); // 显示对应内容 const contentId = tab.getAttribute('data-content'); if (contentId) { document.getElementById(contentId).style.display = 'block'; } }); });