最新发布 保持始终处于顶部

发布时间: 2020-12-30,浏览量:372
$(function(){ 
 
var $win = $(window) 
 
var $nav = $('.mytoolbar'); 
 
var navTop = $('.mytoolbar').length && $('.mytoolbar').offset().top; 
 
var isFixed=0; 
 
processScroll() 
 
$win.on('scroll', processScroll) 
 
function processScroll() { 
 
var i, scrollTop = $win.scrollTop() 
 
if (scrollTop >= navTop && !isFixed) { 
 
isFixed = 1 
 
$nav.addClass('subnav-fixed') 
 
} else if (scrollTop <= navTop && isFixed) { 
 
isFixed = 0 
 
 $nav.removeClass('subnav-fixed') 
 
} 
 
} 

热门文章 经典语录

热门文章 热门文章

查看更多