あなたのフォームが持っているように見えます
action=""
また
action="#home"
onclickの代わりに関数を呼び出す
onclick="mylinkfunction()"
..。
<script type-"text/javascript">
function mylinkfunction(e) {
window.location.href="#targetDiv";
/* need to stop the form sending of the form
UPDATE as comment: This may not be exactly correct syntax
for stopping a form , look up preventing form submission */
e.preventDefault();
e.stopPropagation();
}
</script>
または、フォームが無関係である場合は、そのアクションを設定し、JavaScriptを完全に削除します
<form action="#targetDiv" method="get">
<input type="submit" value="go"/>
</form>
しかし、必要なのは実際にはこれだけです。
<a href="#targetDiv">click me</a>
「別のdivに移動」とは、ページをジャンプして新しい場所にスクロールすることを意味する場合、実際には移動する必要のあるアンカーです。
<a name="targetDiv"/>