Hello,
I'm new to jQuery and tought to give myself a small challenge. I wanted to make my own jQuery slider (for div's or images) without any plugins.
When the document is loaded it changes the first div class to 'current'.
This is my div lay-out.
Code:
<div id="up"></div>
<div class="test" class="slide">1</div>
<div class="test" class="slide">2</div>
<div class="test" class="slide">3</div>
<div class="test" class="slide">4</div>
<div class="test" class="slide">5</div>
<div id="down"></div>
The following code is executed when I click on a div with id 'up':
Code:
if ($('.slide').is(':first')){
console.log("error");
} else {
$('.current').animate({height:0}, 2000, function() {});
$('.current').addClass('test');
$('.current').next('.test').animate({height:300}, 2000, function() {}).addClass('current').removeClass('.test');
$('.current:last').removeClass('current');
}
});
And ofcourse I have similar code for a div with id 'down'.
I think it should work but somehow it does not. When I click a div (up or down) it says, no matter what, 'error'.
The console.log(" ") thing is for firebug.
I hope somebody can show me what is wrong or how I could do the whole thing better. (if even possible)
Thanks,
Jasper