Solved

jQuery scroll to increments

Posted on 2009-07-06
2
1,792 Views
Last Modified: 2012-05-07
This is a rather simple concept, Im not sure how to correctly code it.

Any help asap is greatly appreciated.

Using the jQuery code below, I am scrolling a div, and that works great.

How does one do this incrementally? Meaning pressing the #next_item will jump another 148 pixels, and continue each click.
$(document).ready(function(){
 
$('#next_item').click(function(){
		$('#itinerary_items').stop().scrollTo( 148, 300 );
});
 
 
});

Open in new window

0
Comment
Question by:webrhp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 24789391

var lastValue=0;
$(document).ready(function(){
 
$('#next_item').click(function(){
			lastValue+=148;
                $('#itinerary_items').stop().scrollTo( lastValue, 300 );
});
 
 
});

Open in new window

0
 
LVL 6

Expert Comment

by:coolersport
ID: 24790402
This one has all you need http://demos.flesler.com/jquery/scrollTo/. Check relative position or offset method.

Cheers,
Tien
0

Featured Post

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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)
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…

691 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