const $window = $(window) const $document = $(document) const $nav = $('nav') const $next = $nav.next() const nail = e => { console.log($window.scrollTop()) if ($window.scrollTop() > 600) { $nav.addClass('fix-top') $next.addClass('fix-top-next') } else { $nav.removeClass('fix-top') $next.removeClass('fix-top-next') } } $window.on('touchmove', nail) $window.on('scroll', nail)