$(function () { $(".search-submit").click(function (event) { $(this).removeAttr("name"); event.preventDefault(); var val = $.trim($(".search-title").val()); if (val !== "") { $(".wp-search").find("form").submit(); } else { alert("请输入关键词"); } return false; }); $(".goTop").click(function(){ $("body,html").animate({"scrollTop":0},600) }) }); fontSize(); $(window).resize(function () { fontSize(); }); function fontSize() { var size; var winW = window.innerWidth; $("body").removeClass("mobile") if (winW <= 3800 && winW > 1920) { size = Math.round(winW / 19.2); } else if (winW <= 1920 && winW > 1720) { size = 100; } else if (winW <= 1720 && winW > 999) { size = Math.round(winW / 19.2); } else if (winW <= 999) { $("body").addClass("mobile") //size = 65; size = Math.round(winW / 9.9); } $('html').css({ 'font-size': size + 'px' }) } // 禁用页面滚动的函数 function disableScroll() { document.addEventListener('wheel', preventScroll,{passive:false}); //document.addEventListener('mousewheel', preventScroll,{passive:false}); } function enableScroll() { document.removeEventListener('wheel', preventScroll,{passive:false}); //document.removeEventListener('mousewheel', preventScroll,{passive:false}); } function preventScroll(event) { event.preventDefault(); }