Scrolling Div Inside Div Using Link?
i want to scroll to top position of div based id when link clicked... if link beside click so div id 'ltv' move / scroll to top.. this my picture to describe my purpose if anyone
Solution 1:
You can try this:
$('.links').click(function()
{
$('html, body').animate({ scrollTop: $('.section').eq($(this).index()).offset().top }, 1000);
})
Solution 2:
you can use jQuery's scrollTop function
$('#ltv').click(function(e) {
e.preventDefault();
$('#divId').scrollTop(0);
});
If you want this to be like a slide up to the top, you can use it with .animate
:
$('#divId').stop().animate({ scrollTop: "0px" });
if you are wanting a certain div to go to the top, you are gouing to have to work out its y offest and then use that as the scrollTop px
Solution 3:
This might come in handy:
http://demos.flesler.com/jquery/scrollTo/
Basically, it's a jQuery plugin that helps you scroll in different ways to different DOM elements.
Post a Comment for "Scrolling Div Inside Div Using Link?"