Solved

Jquery scroll maximum

Posted on 2010-08-20
5
478 Views
Last Modified: 2012-08-13
I have simple scroller that auto slides and moves on click....

But how do i either make it continuous or stop when it gets to the last item...?

<div id="scroller-container">
  <ul id="scroller">
    <li>Test1</li>
    <li>Test2</li>
  </ul>
</div>
0
Comment
Question by:maccaj51
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33483268
just the get list item element handle using
http://api.jquery.com/last-child-selector/

then you can scroll that element into view using
http://stackoverflow.com/questions/68165/javascript-to-scroll-long-page-to-div/68671#68671
0
 

Author Comment

by:maccaj51
ID: 33483306
would this also work if i have more than two items? e.g.
<div id="scroller-container">
  <ul id="scroller">
    <li>Test1</li>
    <li>Test2</li>
<li>Test3</li>
    <li>Test4</li>
  </ul>
</div>
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 33483331
Yes, if you just want to go to last item, it should work

If you want to go to nth item, then consider this
http://api.jquery.com/nth-child-selector/
0
 

Author Comment

by:maccaj51
ID: 33483388
Here is my current code..

how would i use this...
$('li').last().

and say if last li is at a certain position then hide  class=next

<div id="scroller-container">
  <ul id="scroller">
    <li>Test</li>
    <li>Poo</li>
    <li>Test</li>
    <li>Poo</li>
  </ul>
</div>
<a class="prev">Previous</a> <a class="next">Next</a>

?


0
 

Author Closing Comment

by:maccaj51
ID: 33723717
sorted it eventually
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question