jQuery scrolling UL with hidden overflow

Posted by papermate on Stack Overflow See other posts from Stack Overflow or by papermate
Published on 2009-11-19T05:28:41Z Indexed on 2012/09/23 3:38 UTC
Read the original article Hit count: 179

Filed under:

I have a UL with LI's set to display horizontally. The UL has a fixed width and it's set to hide the overflow. This is so I can display my images, which are to be used in a gallery, neatly. It works and looks nice.

I want to, however, use jQuery to scroll the contents of the UL rather than set the overflow property to auto and be presented with those ugly scroll bars. I recycled some code I used to do the same thing a few weeks back but, back then, I was doing it in DIV's. Much easier, apparently.

$('.gallery_container span').hover(
   if ($(this).attr('class') == 'up')
      direction = '-=';
      direction = '+=';

   var divOffset = $('ul.gallery').offset().top;
   $('ul.gallery').animate({scrollTop: direction + divOffset}, 5000);

I saw a site that says the scrollTop property can be applied to UL's. So I'm not sure what exactly is causing this not to work.

Any ideas?

EDIT: Found what was causing it to not work at all but not it scrolls vertically - Kind of expected that. Is there any way to scroll it horizontally?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about list