Reputation: 38529
I'm developing an app with a kind of multiple part form (step 1, step 2 etc...)
What I'm doing, is separating this out in divs, and having the submit button hide the current div, and show the next one.
I'd like the page to scroll to the top (as if it were a postback) when hiding/showing the next part:
$('#my_submit_button').click(function (){
$('#div_one').hide();
$('#div_two').show();
//now it should scroll to top of window...
$(window).scrollTop(100);
});
However, this isn't working as expected.
Upvotes: 0
Views: 170
Reputation: 3465
$('body').animate({scrollTop : 0},'slow');
use this for the last part.
also use .hide("fast");
and .show("fast")
Upvotes: 1
Reputation: 2571
You could scroll to the top of your div by doing:
$('#my_submit_button').click(function (){
$('#div_one').hide();
$('#div_two').show();
window.location.href = '#div_two';
});
Upvotes: 0