Click here to Skip to main content
15,905,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to animate window scroll from current position
to another position in vertical direction. i used this code

<pre>$("html,body").animate({scrollTop : pos-100} , 500);</pre>


but it scrolls from 0 not current window position, i mean at first it goes to top then scrolls to
desiered position

how can i solve this?

i solved it below, but...
it doesn't work on IE(v10)!!
tested on chrome and it worked

how to solve this cross-browser issue if it is cross-browser?
Posted
Updated 15-Oct-13 2:30am
v2

i solved it myself
you should enter the following code after the animate code

$(a).click(function(){
$("body").animate({"scrollTop" : 0},500);
return false;
});

this way the a tag won't look at it's "href" attribute
 
Share this answer
 
i solved it myself
you should enter the following code after the animate code

$(a).click(function(){
    $("body").animate({"scrollTop":0},500);
    return false;
});

this way the a tag won't look at it's "href" attribute
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900