How can I create a vertical slider with jQuery? Here’s what I’ve got so far:
JSFIDDLE: http://jsfiddle.net/vkA2w/
HTML:
<div id="vslider">
<div id="vslidernav">
<ul>
<a id="1"><li>Box 1</li></a>
<a id="2"><li>Box 2</li></a>
<a id="3"><li>Box 3</li></a>
<a id="4"><li>Box 4</li></a>
<a id="5"><li>Box 5</li></a>
</ul>
</div>
<div id="vsliderboxes">
<div id="box1" class="active"><h1>Clean Interface Design</h1></div>
<div id="box2" class="inactive"><h1>Efficient Code For Faster Loads</h1></div>
<div id="box3" class="inactive"><h1>Work Within Any Budget</h1></div>
<div id="box4" class="inactive"><h1>Less Time Building, More Time Using</h1></div>
<div id="box5" class="inactive"><h1>Powerful Applications</h1></div>
</div>
</div>
jQuery:
$(function(){
boxheight = $('.box').height()
nextbox = $('.active').next()
function clickslide(){
};
function autoslide(){
$(nextbox).animate(function(){scrollTop: boxheight}).addClass('active').prev().removeClass('active')
};
$('#vslidernav ul a').click(clickslide)
window.setInterval(autoslide, 2000)
});
Why doesn’t that work? The variable ‘next box’ picks the active box, then should select the box immediately after it. Then the autoslide function should slide it down. Then it gives itself the active class and removes it from the previous box.
But it doesn’t work! Why? Thanks.
Demo: http://jsfiddle.net/vkA2w/4/
UPDATE
As a bonus, here is a method to get the navigation links working:
UPDATE
Ok last update, here is a demo: http://jsfiddle.net/vkA2w/8/
JS–
HTML —
CSS —