$(function() {
var onScroll;
onScroll = function(e) {
var $nav_items, active_cls, scrollPos;
scrollPos = $(document).scrollTop() + 91;
$nav_items = $('.menu-box').find('.link');
active_cls = '-active';
return $nav_items.each(function() {
var $refElement, refElement_height;
$refElement = $($(this).attr('href'));
refElement_height = $refElement.height() + parseInt($refElement.css('paddingBottom')) + parseInt($refElement.css('paddingTop'));
if ($refElement.length) {
if ($refElement.offset().top <= scrollPos && $refElement.offset().top + refElement_height > scrollPos) {
$nav_items.removeClass(active_cls);
return $(this).addClass(active_cls);
} else {
return $(this).removeClass(active_cls);
}
}
});
};
<div class="container">
<a href="/" class="home">Главная</a>
<div class="form-box">
<form role="search" method="get" class="flex" action="form.php" >
<input type="search" class="search_field_menu" placeholder="Поиск по сайту" required autocomplete="off" value="" />
<button type="submit" class="search_submit_menu" value="найти"></button>
</form>
</div>
<?php
wp_nav_menu( array(
'theme_location' => 'nav_top',
'container' => 'nav',
'menu_class' => '',
'items_wrap' => '<ul>%3$s</ul>'
));
?>
</div>