How to implement the navigation and logo attached to the screen?

Hello, tell me how to do the logo and the navigation menu was attached only with 2 or more screens, and the first was not displayed in the landing page, as implemented here:
June 5th 19 at 21:50
1 answer
June 5th 19 at 21:52
$(window).scroll(function() {
 var top = $(document).scrollTop();
 if (top < 300) $(".top_nav").removeClass('fixed');
 else $(".top_nav").addClass('fixed');

 position: fixed;

Find more questions by tags BootstrapLayout