This answer by sg3s on how to use jQuery (from someone's question) to slide divs horizontally is exactly what I want to do. However, I can't for the life of me figure out the jQuery code.
jQuery(function($) {
$('a.panel').click(function() {
var $target = $($(this).attr('href')),
$other = $target.siblings('.active');
if (!$target.hasClass('active')) {
$other.each(function(index, self) {
var $this = $(this);
$this.removeClass('active').animate({
left: $this.width()
}, 500);
});
$target.addClass('active').show().css({
left: -($target.width())
}).animate({
left: 0
}, 500);
}
});
});
I get stuck on the if statement and the reason for the active class and .animate on both statements within it. Can someone please run me through this bit of jQuery? Instead of just using the solution, I'd love to understand it.
Thanks!