Hello,
I have a jQuery problem, and I've really tried everything I know (i am so newbie at this) so ..
The problem in short is I am doing a simple carousel-like effect. I am using this code.
(The div .showarea is the DIV which needs to be rotated (next/prev) but I want to keep only one div shown at a time.)
This is the html markup.
<div class="maincarousel">
<div class="showarea"><a href="#"><img src="img/sampleshow.png" alt="" title="" /></a></div>
<div class="showarea"><a href="#"><img src="img/sampleshow2.png" alt="" title="" /></a></div>
<div class="showarea"><a href="#"><img src="img/sampleshow3.png" alt="" title="" /></a></div>
<a href="#carouselPrev" class="leftarrow" title="Previous"></a>
<a href="#carouselNext" class="rightarrow" title="Next"></a>
</div>
This is my jquery attempt
$('.showarea').hide();
$('.showarea:first').fadeIn(500);
$('.maincarousel a').click(function () {
if ($(this).attr('href') == '#carouselNext') {
$('.showarea').hide();
$('.showarea').next('.showarea').fadeIn(500);
}
if ($(this).attr('href') == '#carouselPrev') {
$('.showarea').hide();
$('.showarea').prev('.showarea').fadeIn(500);
}
});
Unfortunately, next() and prev() won't display the next element only, but all next elements and same thing for prev(). Any quick workaround..
Can someone help me on this,
Thanks