sliderlll

klj

HTML

<div id="slider-wrapper">
        <div id="slider">
            <div class="sp" style="background: blue;">1</div>
            <div class="sp" style="background: yellow;">2</div>
            <div class="sp" style="background: green;" >3</div>
            <div class="sp" style="background: red;">4</div>
        </div>

        </div>

<div id="nav">
                <div id="button-previous">prev</div>
            <div id="button-next">next</div>
</div>

<div id="hidden" style="display:none;">Div Oculto</div>

CSS

#slider-wrapper {width:500px; height:200px; font-size:55px; color:#FFF;}
#slider {width:500px; height:200px; position:relative;}
.sp {width:500px; height:200px; position:absolute;}

#nav {margin-top:20px; width:100%;}
#button-previous {float:left;}
#button-next {float:right;}

JavaScript

$(document).ready(function(){
$('.sp').first().addClass('active');
$('.sp').hide();    
$('.active').show();

    $('#button-next').click(function(){

    $('.active').removeClass('active').addClass('oldActive');    
                   if ( $('.oldActive').is(':last-child')) {
        $('.sp').first().addClass('active');
        }
        else{
        $('.oldActive').next().addClass('active');
        }
    $('.oldActive').removeClass('oldActive');
    $('.sp').fadeOut();
    $('.active').fadeIn();
        
        
    });
    
       $('#button-previous').click(function(){
    $('.active').removeClass('active').addClass('oldActive');    
           if ( $('.oldActive').is(':first-child')) {
        $('.sp').last().addClass('active');
        }
           else{
    $('.oldActive').prev().addClass('active');
           }
    $('.oldActive').removeClass('oldActive');
    $('.sp').fadeOut();
    $('.active').fadeIn();
    });
    
    
    
    
});