I want to create a side scroll menu like here. What I have:
HTML:
<div class="scroll">
<p class="scroll_item" id="1"> </p>
<p class="scroll_item" id="2"> </p>
<p class="scroll_item" id="3"> </p>
<p class="scroll_item" id="4"> </p>
</div>
<div id="first"> 1 </div>
<div id="second"> 2 </div>
<div id="third"> 3 </div>
<div id="fourth"> 4 </div>
CSS:
.scroll{
position:fixed;
height:48%;
right:4px;
top:48%
}
.scroll_item{
margin-bottom:10px;
width:10px;
height:10px;
border: 3px solid #FFF;
}
.scroll_item_active{
width:10px;
height:10px;
border:3px solid #FFF;
background-color: #FFF;
margin-bottom: 10px;
}
How this should work:
When you click on the <p> with the id 3, it will scroll to the div with the id "third", and the box will have the scroll_item_active class. On the other hand, if you use the browser's scrollbar, the box's class will still be changed.
I need your help to code the jQuery script. What I've done:
$('#1').onclick(function(.scrollTo('#first');)
$('#2').onclick(function(.scrollTo('#second');)
$('#3').onclick(function(.scrollTo('#third');)
$('#4').onclick(function(.scrollTo('#fourth');)
.scrollTo('#fourth');. Like$('body, html').scrollTo()or$(document)