$(function() { //搜索栏点击出现 $('body').on('click','.headerSearch img',function(){ $('.header').addClass('on'); $('.headerSearch_box').addClass('on').fadeIn(300); }) //搜索栏点击消失 $('body').on('click','.headerSearch_close',function(){ $('.headerSearch_box').removeClass('on').fadeOut(300); }) //页面向下滚动 $('body').on('click','.toDown',function(){ $('html, body').animate({scrollTop:$(window).height() - 90},1000) }) //页面返回顶部 $('body').on('click','.toTop',function(){ $('html, body').animate({scrollTop:0},1000) }) //导航栏hover $(".header").hover(function(){ $('.header').stop(true).addClass('header2'); $('.header .headerLogo img').stop(true).attr('src','/index/images/logo2.png'); },function(){ $('.header').stop(true).removeClass('header2'); if ($('.header').hasClass('on')) { $('.header .headerLogo img').stop(true).attr('src','/index/images/logo2.png'); }else{ $('.header .headerLogo img').stop(true).attr('src','/index/images/logoWhite2.png'); } }); //产品中心下拉菜单 $(".headerNav>li").hover(function(){ $(this).find('.headerProduct_box').stop(true).fadeIn(0).addClass('on'); },function(){ $(this).find('.headerProduct_box').stop(true).fadeOut(0).removeClass('on'); }); }) $(window).load(function(){ }) $(window).resize(function(){ }) $(window).scroll(function () { var h = $(window).scrollTop() if (h > 100) { $('.header').addClass('on'); $('.header .headerLogo img').attr('src','/index/images/logo2.png'); }else{ if ($('.headerSearch_box').hasClass('on')) { $('.header').addClass('on'); $('.header .headerLogo img').attr('src','/index/images/logo2.png'); }else{ $('.header').removeClass('on'); $('.header .headerLogo img').attr('src','/index/images/logoWhite2.png'); } } if (h > 100) { $('.header2').addClass('on'); $('.header2 .headerLogo img').attr('src','/index/images/logo2.png'); }else{ $('.header2').removeClass('on'); $('.header2 .headerLogo img').attr('src','/index/images/logo2.png'); } })