I've got the following code. At the moment, it only scrolls down the height of a variable.
http://jsfiddle.net/tmyie/gF6U3/1/
$('.col100').click(function(e){
e.preventDefault();
var H = $('.col100').outerHeight();
$('html, body').animate({scrollTop: H}, 200);
});
Questions:
You are scrolling to the same position each time. Easiest would be to calculate the offset position of the next box:
$('.col100').click(function(e){
e.preventDefault();
var H = $(this).next().offset().top;
$('html, body').animate({scrollTop: H}, 200);
});
Note that this doesn't handle what to do at the last box.. depends on how you want to implement it.
use this - http://jsfiddle.net/gF6U3/3/
$('.col100').click(function(e){
e.preventDefault();
var H = $(this).next('.col100').offset().top;
$('html, body').animate({scrollTop: H}, 200);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.