/** * Created by Administrator on 2017/1/16. */ $(function () { //加载公用部分,写程序的时候记得删除!! $("header").load("header.html"); $("footer").load("footer.html"); //$(".sidebar").load("sidebar.html"); if (window.innerWidth >= 640) { $(".cloud-product-ul li").hover(function () { $(this).addClass("active").siblings().removeClass("active"); }) $(".solution-list ul li").hover(function () { $(this).addClass("active").siblings().removeClass("active"); }) } else { $('.cloud-product-ul li').filter(':even').removeClass("active").addClass('active'); $('.i_solution p').text('...'); $('.nproduct_list2 .f24').next().text('...') } // 监听页面滚动,当滚动超过首屏高度时给header添加active类 let windowHeight = $(window).height(); // 获取窗口高度作为首屏高度判断标准 $(window).scroll(function() { let scrollTop = $(window).scrollTop(); if (scrollTop > windowHeight) { $('.home-header .header-v1').addClass('active'); } else { $('.home-header .header-v1').removeClass('active'); } }); });