我有这个带注册表单的HTML代码,点击后我需要滚动页面 按钮与类.reg。问题是页面只滚动到表格的边框。
<div class='registration borders'>
<form action="{$web_path}/model/user/userRegistration.php" method="post">
<input class='user' type='text' name='user' autofocus required placeholder="uživatelské jméno">
<input class='email' type='email' name='email' required placeholder="Váš e-mail">
<input class='password' type='password' name='password' required placeholder="uživatelské heslo">
<button class='reg' type='submit' name='registration_sent'>ZAREGISTROVAT</button>
</form>
</div>
Javascript代码
$(document).ready(function () {
var button_reg = $('button.reg');
button_reg.click(function () {
// scroll top
$('html, body').animate({
scrollTop: 0
}, 'slow');
});
// end jquery
return false;
});
答案 0 :(得分:0)
尝试这样的事情:
$(document).ready(function(){
$('#button').click(function(){
$('html, body').animate({scrollTop: $("#your_respective_div").offset().top}, 1000);
});
})