jquery "scroll" problem
I am trying to modify this script;
<script>
function doIt2() {
$("div.formbut").hide("slow");
$("div.inqform").show("slow");
}
$("submit2").click(doIt2);
$("form").submit(function () {
if ($("input").val() == "yes") {
$("p").show(4000, function () {
$(this).text("Ok, loaded! (now showing)");
});
}
$("div.rates").hide("slow");
$("div.ratesbut").hide("slow");
$("div.inqform").hide("slow");
$("div.done").show("slow");
开发者_如何学Python return false;
});
</script>
What I wanted to do is, scroll to the top of the "inqform" div. could not.. Then tried to scroll to bottom of the page.. I could not do that either.. I wanted it to happen after " $("div.inqform").show("slow"); " I do not understand much of js..
Can anybody help ?
Thanks in advance..
Just insert below code after $("div.inqform").show("slow");
to scroll to top of it -
var targetOffset = $('div.inqform').offset().top;
$('html,body').animate({scrollTop: targetOffset}, 500);
Trying to put this script live.. but noticed that the form is not being posted.
there is a inquiry form in the div.inqform
$("div.inqform").hide("slow");
The done
action is done.. but the form is not posted.
wondering.. now.. do we need to wait document.ready
until form is submitted to show div.done ?
精彩评论