javascript - How to scroll to my button? .scrollTo() not work -
just simple photo viewer.
but don't know how scroll down/up via button.
i tried use jquery .scrollto(y-offset), doesn't work.
here function:
function scrolldown() { var $chapters = $('#dcontent').children('.scontent'); var $chscrollpositions = new array(); $chapters.each(function (i) { $chscrollpositions[i] = math.round($(this).offset().top - $('#dcontent').offset().top) - 10; //alert($chscrollpositions[i]); }); var last = $chapters.parent().find('.active').removeclass('active').index(); var next = (last + 1 == $chapters.length) ? 0 : last + 1; // loop around first chapter $chapters.eq(next).addclass('active'); // set next chapter active $('#dcontnet').scrollto($chscrollpositions[next]); } can please me?
thanks.
use animate that
$("html:not(:animated),body:not(:animated)").animate({ scrolltop: 1000}, 300);
Comments
Post a Comment