$(document).ready(function() { /* 顶部菜单开始 */ $("#menu>.item").mouseover(function() { var menu = $(this).find(">a").siblings(".menu"); menu.fadeIn(300); }); $("#menu>.item").mouseleave(function() { var menu = $(this).find(".menu"); menu.fadeOut(200); }); $("#menu>.item>.menu>.item").mouseover(function() { var menu = $(this).find(">.menu"); menu.fadeIn(300); }); $("#menu>.item>.menu>.item").mouseleave(function() { var menu = $(this).find(">.menu"); menu.fadeOut(300); }); /* 顶部菜单结束 */ /* 首页轮播图开始 */ var interval = 5000; // 轮播图自动切换间隔在这里设置 var carouselInterval = setInterval(nextCarousel, interval); function nextCarousel() { var currentIndex = $(".carousel .active.circle").attr("index"); if(currentIndex < 4) { var nextIndex = parseInt(currentIndex) + 1; } else { var nextIndex = 1; } activeCarousel(nextIndex); } function activeCarousel(index) { // 处理轮播图控制原点的切换 $(".carousel .active.circle").removeClass("active"); $(".carousel .circle[index=" + index + "]").addClass("active"); // 处理轮播图的切换 $(".current.carousel").hide(); $(".carousel.image[index=" + index + "]").addClass("current").fadeIn(1000); $(".carousel.content[index=" + index + "]").addClass("current").show(); clearInterval(carouselInterval); carouselInterval = setInterval(nextCarousel, interval); } $(".carousel li").click(function() { var index = $(this).attr("index"); activeCarousel(index); }); /* 首页轮播图结束 */ /* 标签页切换开始 */ $(".tab .item").hover(function() { $(this).siblings().removeClass("active"); $(this).addClass("active"); var index = $(this).attr("tab-index"); var parent = $(this).parent(); var activePage = parent.siblings(".tab.page[tab-index='" + index + "']"); parent.siblings(".active.tab.page").removeClass("active"); activePage.addClass("active"); // 对于科学传播区,确保切换到某一标签页时,该标签页的第一项的图片能正确显示出来。 var items = activePage.find(".dynamic.feature.image").find(".item"); if(items.length > 0) { items.first().siblings("img").addClass("active"); } }); /* 标签页切换结束 */ /* 科学传播区展示图的切换开始 */ $("ol .item").hover(function() { var list = $(this); var photo = list.next("img"); $("ol a .active.item").removeClass("active"); $("ol .active.image").removeClass("active"); list.addClass("active"); photo.addClass("active"); }); /* 科学传播区展示图的切换结束 */ /* 创新服务区图标浮动效果开始 */ $("#innovation td").mouseover(function() { $(this).find(".normal").hide(); $(this).find(".hover").show(); }); $("#innovation td").mouseleave(function() { $(this).find(".normal").show(); $(this).find(".hover").hide(); }); /* 创新服务区图标浮动效果结束 */ /* 相关网站区图标的浮动效果开始 */ $("#website .item").mouseover(function() { $(this).find('.icon').css("border-color", "#bc010b"); $(this).find(".icon .normal").hide(); $(this).find(".icon .hover").show(); }); $("#website .item").mouseleave(function() { $(this).find('.icon').css("border-color", "#acacac"); $(this).find(".icon .normal").show(); $(this).find(".icon .hover").hide(); }); /* 相关网站区图标的浮动效果结束 */ /* 问卷统计和意见箱的浮动效果开始 */ $("#tools .item").mouseover(function() { $(this).find('.icon').css("border-color", "#bc010b"); $(this).find(".normal").hide(); $(this).find(".hover").show(); }); $("#tools .item").mouseleave(function() { $(this).find('.icon').css("border-color", "#2b90ce"); $(this).find(".normal").show(); $(this).find(".hover").hide(); }); /* 问卷统计和意见箱的浮动效果结束 */ /* 更多图标的浮动效果开始 */ $(".more.icon").mouseover(function() { $(this).find(".normal").hide(); $(this).find(".hover").show(); }); $(".more.icon").mouseleave(function() { $(this).find(".normal").show(); $(this).find(".hover").hide(); }); /* 更多图标的浮动效果结束 */ });