2
我有這個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;
});
問題是輸入具有屬性的自動對焦,這是重點投入。當我清楚這一點,所以我只能使用重定向到主頁和頁面刷新到默認位置。 –