Posted By

jgiuffrida on 05/06/10


Tagged


Versions (?)

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


 / Published in: JavaScript
 

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

  1. $(document).ready(function() {
  2. var theLoc = $('#leftNav').position().top;
  3. $(window).scroll(function() {
  4. if(theLoc >= $(document).scrollTop()) {
  5. if($('#leftNav').hasClass('fixed')) {
  6. $('#leftNav').removeClass('fixed');
  7. }
  8. } else {
  9. if(!$('#leftNav').hasClass('fixed')) {
  10. $('#leftNav').addClass('fixed');
  11. }
  12. }
  13. });
  14. });

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jgiuffrida on May 6, 2010

test

You need to login to post a comment.