< jQuery(document).ready(function($) { function sticky() { var window_top=$(window).scrollTop() > 175; var top_position=$('body').offset().top; var element_to_stick=$('#navi'); if (window_top > top_position) { element_to_stick.addClass('sticky'); } else { element_to_stick.removeClass('sticky'); } } $(window).scroll(sticky); sticky(); >