Solved

Jquery scroll maximum

Posted on 2010-08-20
5
473 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now