window onscroll position fixed position in jquery

Solutions on MaxInterview for window onscroll position fixed position in jquery by the best coders in the world

showing results for - "window onscroll position fixed position in jquery"
Manuel
12 Jan 2017
1$(function() {
2	var fixadent = $("#fixadent"), pos = fixadent.offset();
3	$(window).scroll(function() { 
4		if ($(this).scrollTop() > (pos.top + 10) && fixadent.css('position') == 'static') {
5			fixadent.addClass('fixed');
6		} else {
7		if ($(this).scrollTop() <= pos.top && fixadent.hasClass('fixed')) { 
8		fixadent.removeClass('fixed');
9	}
10   })
11});