$(function(){ /*下载中心*/ $(".second-xzzx-li").each(function(){ var pdf=$(this).find(".second-xzzx-h4").find("a[title]").attr("href"); if(pdf.substr(pdf.length-3,pdf.length)=='pdf') { var rar=pdf.substr(0,pdf.length-3)+"rar"; var zip=pdf.substr(0,pdf.length-3)+"zip"; $(this).find(".second-xzzx-pdf").find("a").attr("href",pdf); $(this).find(".second-xzzx-rar").find("a").attr("href",rar); $(this).find(".second-xzzx-zip").find("a").attr("href",zip); } }); $('.menu-btn').click(function(){ if ($(this).hasClass('active')) { $(this).removeClass('active').attr('src','/portals/82/Skins/sinochem-index-m/images/zhjt-home-tbtn.png') $('.zhjt-menu-box').fadeOut(); $('body').removeClass('modal-open'); document.scrollingElement.scrollTop = scrollTop; } else{ $(this).addClass('active').attr('src','/portals/82/Skins/sinochem-index-m/images/zhjt-home-close.png') $('.zhjt-menu-box').fadeIn() scrollTop = document.scrollingElement.scrollTop; $('body').addClass('modal-open'); document.body.style.top = -scrollTop + 'px'; } }) $('.zhjt-menu>li>div').click(function(){ if ($(this).parent('li').hasClass('active')) { $(this).parent('li').removeClass('active').find('.menu-list').hide() } else{ $(this).parent('li').addClass('active').find('.menu-list').show().parent().siblings().removeClass('active').find('.menu-list').hide() } }) }) $(document).ready(function(){ /*底部折叠*/ $('.footer-list-btn').click(function(){ if($(this).hasClass('active')){ $(this).removeClass('active').find('img').attr('src','/portals/82/Skins/sinochem-index-m/images/home-footer-xia.png') $(this).siblings().hide() }else{ $(this).addClass('active').find('img').attr('src','/portals/82/Skins/sinochem-index-m/images/home-footer-shang.png') $(this).parent().siblings().find('.footer-list-btn').removeClass('active').find('img').attr('src','/portals/82/Skins/sinochem-index-m/images/home-footer-xia.png').parent().siblings().hide() $(this).siblings().show() } }) /*返回顶部*/ $('.zhjt-backtop').click(function(){ $("html,body").animate({scrollTop:0}, 500); }) /*中英文切换 $('.zhjt-language-box').click(function(){ if ($(this).hasClass('on')) { } else{ $(this).addClass('on').siblings().stop().fadeIn() } }) $('.language-shade').click(function(){ $(this).stop().fadeOut().siblings('div').removeClass('on').siblings('ul').fadeOut() })*/ }) $(window).scroll(function(event){ var winPos = $(document).scrollTop(); if(winPos > 50){ $('.zhjt-home-top').addClass('scroll') $('.zhjt-menu-box').addClass('scroll') }else{ $('.zhjt-home-top').removeClass('scroll') $('.zhjt-menu-box').removeClass('scroll') } var scrollTop = $(this).scrollTop(); var scrollHeight = $(document).height(); var windowHeight = $(this).height(); if(scrollTop + windowHeight >= scrollHeight - 1200){ //当滚动到底部时,执行此代码框中的代码 $('.zhjt-backtop').show() }else{ $('.zhjt-backtop').hide() } });