Hello everyone!
I got a question about a basic things with javascript for navigation bar.
In many sites used the following snippset:
var $test_top_div = $(‘#test_top_div’);
var test_top_balance = $test_top_div.offset().top;
$(window).scroll(function() {
if ($(window).scrollTop() >= test_top_balance) {
$(‘#test_top_div’).addClass(‘test_sticky’);
}
else {
$(‘test_top_div’).removeClass(‘test_sticky’);
}
});
I use this with above a viewport units image slider. So that means when user scroll to test_top_balance div is got display with position: fixed; on top.
My QUESTION how can add extra 60px (my nav height is 60 px) when te user still not scroll towards to get position fixed? I try something like operators != but is not really work?