$(function () { // PC广告图轮播 $('#flash .flexslider').flexslider({ animation: "slide", slideshowSpeed: 5000, directionNav: true, }); //手机广告图轮播 $('#mobile_flash .flexslider').flexslider({ animation: "slide", slideshowSpeed: 5000, directionNav: true, }); // 页面滚动顶部悬浮 window.addEventListener("scroll", function (e) { //变量t就是滚动条滚动时,到顶部的距离,变量_h是顶部header的高度 var _t = document.documentElement.scrollTop || document.body.scrollTop; var _h = document.getElementById("header").clientHeight; if (_t > _h) { document.getElementById("header").className = "float_header"; } else { document.getElementById("header").className = ""; } }); });