Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  150] [ 1]  / answers: 1 / hits: 24010  / 12 Years ago, thu, november 1, 2012, 12:00:00

enter
The left is the what I'm trying to scroll...it scrolls just a little bit and then stops. It seems to scroll the same amount each time too.


I am trying to get the scrollTop using jQuery to work on page load when the content I am trying to scroll to is located in within a div. The current implementation doesn't do anything


javascript


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>

<script>
$(document).ready(function (){
//$(this).animate(function(){
$('html, body').animate({
scrollTop: $("#test4").offset().top
}, 2000);
//});
});
</script>

html


<div class="row">
<div class = "span12">

<div class = "row">

<div class = "span2">

<div style="height:480px;font:12px Georgia, Garamond, Serif;overflow:auto;">

<div id = "test1">Test1</div>
<div id = "test2">Test2</div>
<div id = "test3">Test3</div>
<div id = "test4">Test4</div>

</div>
</div>


<div class = "row">
<div class = "span8">
Other content on the page
</div>
</div>

</div>
</div>
</div>

More From » jquery

 Answers
9

I have changed your code little bit you can find the fiddle here.



this is the js code i have used:



$('.sss').animate({
scrollTop: $(.test5).offset().top
}, 2000);​


here



$('.sss')


is the holder which holds the sidelinks


[#82257] Tuesday, October 30, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gregoriocoya

Total Points: 549
Total Questions: 111
Total Answers: 104

Location: Saint Helena
Member since Mon, Jan 16, 2023
1 Year ago
;