$(window).scroll(function () { if ($(this).scrollTop() > 200) { // 当向下滚动超过100px时 // console.log("用户已经滚动到了页面的200px位置"); // 这里可以执行更多的操作,比如显示一个返回顶部的按钮等 $(".header .thd").hide(); $(".header").addClass("header-bg"); } else { $(".header .thd").show(); $(".header").removeClass("header-bg"); } }); $(".nav-btn").click(function () { $('body').toggleClass("nav-show"); }) $(".toggle").click(function () { $(this).toggleClass("open"); $('.section-nav .sub-nav .wp ul').toggleClass("show"); }) $(".nav ul li .name i.icon-plus").click(function () { $(this).parent().next().slideToggle(); $(this).parent().parent().siblings('li').find('.sub').slideUp() }) $(function(){ //菜单隐藏展开 var index=0 $('#hy .tab-hd').eq(0).find('i').addClass("cur"); $('#hy .tab-bd').eq(0).show(); $('#hy .tab-hd').click(function(){ var i = $('#hy .tab-hd').index($(this)); // console.log("index:",i); if( index == i ) return false; index = i; $('#hy .tab-hd').eq(index).addClass("cur").siblings().removeClass("cur"); $('#hy .tab-bd').slideUp().eq(index).slideDown(); }); }) $(document).ready(function() { // 首页浮窗 $('.advbox').fadeIn(2000); $('.advbox .closebtn').click(function(){ $('.advbox').fadeOut(); }); // 详情页字体放大缩小 var originalFontSize = $('.content .con').css('font-size'); // 获取原始字体大小 $('.small-size').click(function() { var currentFontSize = $('.content .con').css('font-size'); var fontSize = (currentFontSize.match(/(\d+)/)) ? parseInt(currentFontSize.match(/(\d+)/)[1], 10) : 16; // 提取字体大小数值 fontSize = (fontSize-2)/100; // 减小字体大小 $('.content .con').css('font-size', fontSize + 'rem'); // 应用新的字体大小 }); $('.normal-size').click(function() { var fontSize = (originalFontSize.match(/(\d+)/)) ? parseInt(originalFontSize.match(/(\d+)/)[1], 10) : 16; // 提取字体大小数值 fontSize = fontSize/100; $('.content .con').css('font-size', fontSize + 'rem'); // 应用新的字体大小 }); $('.large-size').click(function() { var currentFontSize = $('.content .con').css('font-size'); var fontSize = (currentFontSize.match(/(\d+)/)) ? parseInt(currentFontSize.match(/(\d+)/)[1], 10) : 16; // 提取字体大小数值 fontSize = (fontSize+2)/100; // 增加字体大小 $('.content .con').css('font-size', fontSize + 'rem'); // 应用新的字体大小 }); });