Return to Snippet

Revision: 26701
at May 6, 2010 21:03 by jgiuffrida


Updated Code
$(document).ready(function() {
	var theLoc = $('#leftNav').position().top;
	$(window).scroll(function() {
		if(theLoc >= $(document).scrollTop()) {
			if($('#leftNav').hasClass('fixed')) {
				$('#leftNav').removeClass('fixed');
			}
		} else { 
			if(!$('#leftNav').hasClass('fixed')) {
				$('#leftNav').addClass('fixed');
			}
		}
	});
});

Revision: 26700
at May 6, 2010 20:13 by jgiuffrida


Updated Code
$(document).ready(function() {
	var theLoc = $('#leftNav').position().top;
	$(window).scroll(function() {
		(theLoc >= $(document).scrollTop()) 
		? $('#leftNav').removeClass('fixed') 
		: $('#leftNav').addClass('fixed');	
	});
});

Revision: 26699
at May 6, 2010 20:13 by jgiuffrida


Updated Code
$(document).ready(function() {
	var theLoc = $('#leftNav').position().top;
	$(window).scroll(function() {
		(theLoc >= $(document).scrollTop()) 
		? $('#leftNav').removeClass('fixed') 
		: $('#leftNav').addClass('fixed');	
	});
}

Revision: 26698
at May 6, 2010 20:06 by jgiuffrida


Initial Code
$(document).ready(function() {
	var theLoc = $('#leftNav').position().top;
	$(window).scroll(function() {
		(theLoc >= $(document).scrollTop()) ? $('#leftNav').removeClass('fixed') : $('#leftNav').addClass('fixed');
	});
}

Initial URL
http://www.josephgiuffrida.com/

Initial Description


Initial Title
Using jQuery to Create a Fixed Sidebar - JS - fixedSide.js

Initial Tags


Initial Language
JavaScript