I've got 4 divs and on click of the navigation I want to show one of them and hide the others. I have it working but I feel its not as smooth as I know it could be, its definitely my code that needs to be refactored! Heres what I have.
$('#details-speakers').click(function() {
$('#home').slideUp('slow', function() {});
$('#sessions-content').slideUp('slow', function() {});
$('#cases-content').slideUp('slow', function() {});
$('html,body').animate({scrollTop: $("#details").offset().top - 16}, 200, "swing");
$('#speakers-content').slideDown('slow', function() {
$('#details-speakers').addClass('selected');
//Remove other classes
$('#details-sessions').removeClass('selected');
$('#details-cases').removeClass('selected');
$('#details-workshops').removeClass('selected');
});
});
$('#details-sessions').click(function() {
$('#home').slideUp('slow', function() {});
$('#speakers-content').slideUp('slow', function() {});
$('#cases-content').slideUp('slow', function() {});
$('html,body').animate({scrollTop: $("#details").offset().top - 16}, 200, "swing");
$('#sessions-content').slideDown('slow', function() {
$('#details-sessions').addClass('selected');
//Remove other classes
$('#details-speakers').removeClass('selected');
$('#details-cases').removeClass('selected');
$('#details-workshops').removeClass('selected');
});
});
$('#details-cases').click(function() {
$('#home').slideUp('slow', function() {});
$('#speakers-content').slideUp('slow', function() {});
$('#sessions-content').slideUp('slow', function() {});
$('html,body').animate({scrollTop: $("#details").offset().top - 16}, 200, "swing");
$('#cases-content').slideDown('slow', function() {
$('#details-cases').addClass('selected');
//Remove other classes
$('#details-speakers').removeClass('selected');
$('#details-sessions').removeClass('selected');
$('#details-workshops').removeClass('selected');
});
});