Files
orico-official-website/public/static/index/js/headfoot.js

51 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//加载公共头部和尾部
async function loadHTML(url, targetId) {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const html = await response.text();
document.getElementById(targetId).innerHTML = html;
} catch (error) {
console.error('Error loading HTML:', error);
}
}
// 加载头部
loadHTML('head.html', 'header');
// 加载尾部
loadHTML('footer.html', 'footer');
$(document).ready(function() {
// 封装一个函数用于处理鼠标悬停显示和隐藏内容
function handleHover($element, $content) {
$element.mouseenter(function() {
$content.stop(true, true).slideDown(400);
}).mouseleave(function() {
$content.stop(true, true).slideUp(400);
});
}
// 处理第一个导航项
handleHover($('.navItem').eq(0), $('.navItem').eq(0).find('.navItemConten'));
// 鼠标移入navItem_cyleft里面的li标签添加类移除其他li的类
$('.navItem_cyleft li').mouseenter(function() {
$(this).addClass('it_active').siblings().removeClass('it_active');
});
// 处理第5 - 8个导航项
for (let i = 4; i < 8; i++) {
handleHover($('.navItem').eq(i), $('.navItem').eq(i).find('.navItemConten1'));
}
// 点击搜索
$('#openModalBtn').click(function() {
$('#scmodal').toggle();
});
$('.close-btn').click(function() {
$('#scmodal').hide();
});
// 点击选择国家
$('#countrycheck').click(function() {
$('#top-country').toggle();
});
$('.closecountrybt').click(function() {
$('#top-country').hide();
});
});