I have a simple menu with fixed position and some text inside it and some boxes under this menu(divs). I'm searching for a code that when I click on one of the texts that inside menu the page autoscrolls to a div of the divs down, indeed I found this code but it's incomplete because when the page autoscroll to a div if you want the page to scroll to another div up to this div it can't autoscroll, I mean it doesn't scroll up only scrolls down. The code of the menu and the text:
<style>
#menu {
background-color: #ccc;
position:fixed;
width:100%
}
.menutext {
padding:25 40 0 !important;
display:inline-block;
}
.alldivs {
width:300px;
height:200px;
background-color:a9a9a9;
}
</style>
<div id="menu">
<div class="menutext">Auto-scroll to (DIV1) onclick on me</div>
<div class="menutext">Auto-scroll to (DIV2) onclick on me</div>
<div class="menutext">Auto-scroll to (DIV3) onclick on me</dive>
<div class="menutext">Auto-scroll to (DIV4) onclick on me</div>
</div>
<br><br><br>
<div class="alldivs"><div id="DIV1">DIV1</div></div>
<div class="alldivs"><div id="DIV2">DIV2</div></div>
<div class="alldivs"><div id="DIV3">DIV3</div></div>
<div class="alldivs"><div id="DIV4">DIV4</div></div>
Simply, I want when I press on "Auto-scroll to (DIV1) onclick on me" the page autoscroll to the div "DIV1" and when I press on "Auto-scroll to (DIV3) onclick on me" the page autoscroll to "DIV3" BUT NOTE THAT*** WHEN I WANT TO SCROLL UP TO A DIV UP THE CODE ABLE TO DO THAT(TO SCROLL UP), for example:when I press on "Auto-scroll to (DIV3) onclick on me" the page scrolls to "DIV3" but then when I press to "Auto-scroll to (DIV2) onclick on me" the code should be able to let the page scrolls to "DIV2".(also note that it's fixed menu)