rn false; // } // else if (con_name=='Code' && act_name=='detail') // else // { // } var navigation_height = $('.top_nav').outerHeight(); console.log(navigation_height); $(window).scroll(function() { //触发滚动事件后,滚动条的高度(本次高度) var end_height = $(document).scrollTop(); console.log(end_height); // console.log(end_height,start_height,'end',navigation_height); //触发后的高度 与 元素的高度对比 if (end_height > navigation_height){ $(".top_nav").addClass("active"); // $('.navbar').css('top', '-50px'); }else { $(".top_nav").removeClass("active"); } //触发后的高度 与 上次触发后的高度 if (end_height < start_height) { } //再次获取滚动条的高度,用于下次触发事件后的对比 start_height = $(document).scrollTop(); }); });