My goal is to create a user interface where users can navigate through different divs. Here is the HTML code:
<article id="realize" class="realizeBox">
<div class="shown">
<div class="heading">
<h2>Realisations: <span>AGFA</span></h2>
</div>
<div class="centering">
<aside class="left">
<p>Maecenas laoreet est bibendum, dictum mi vel, cursus mi. Curabitur feugiat libero vitae lorem venenatis consequat. Donec luctus nisi cursus miet sapien blandit, quis congue massa tincidunt.</p>
</aside>
<aside class="right">
<p>Maecenas laoreet est bibendum, dictum mi vel, cursus mi. Curabitur feugiat libero vitae lorem venenatis consequat. Donec luctus nisi cursus miet sapien blandit, quis congue massa tincidunt.</p>
</aside>
<div class="clear"></div>
</div>
<div class="button">
<div class="centering"> <a href="#" class="next"></a> <a href="#" class="prv"></a> </div>
</div>
</div>
<div class="notshown">
<div class="heading">
<h2>Realisations: <span>TEST</span></h2>
</div>
<div class="centering">
<aside class="left">
<p>Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Etiam porta sem malesuada magna mollis euismod. Donec ullamcorper nulla non metus auctor fringilla.</p>
</aside>
<aside class="right">
<p>Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Etiam porta sem malesuada magna mollis euismod. Donec ullamcorper nulla non metus auctor fringilla.</p>
</aside>
<div class="clear"></div>
</div>
<div class="button">
<div class="centering"> <a href="#" class="next"></a> <a href="#" class="prv"></a> </div>
</div>
</div>
</article>
In the article, I have multiple divs. The first one is displayed, while the others have the class notshown
with CSS styling of display:none;
.
There are two buttons for each div:
<a href="#" class="next"></a>
<a href="#" class="prv"></a>
The JavaScript associated with this functionality is as follows:
$('.next').click(function(e){
e.preventDefault();
if($('.realizeBox .shown').next().length > 0)
{
$('.realizeBox .shown').removeClass('shown').addClass('notshown').next().addClass('shown').removeClass('notshown');
}
});
$('.prv').click(function(e){
e.preventDefault();
if($('.realizeBox .shown').prev().length > 0)
{
$('.realizeBox .shown').removeClass('shown').addClass('notshown').prev().addClass('shown').removeClass('notshown');
}
});
Currently, the transitions between divs are abrupt, and I would like to incorporate animated effects for smoother navigation. I've attempted using jQuery's animate function without success due to my limited JavaScript skills. Can someone provide guidance on how to achieve this?