Skip to content

Instantly share code, notes, and snippets.

@maplethorpej
Created August 6, 2015 15:52
Show Gist options
  • Save maplethorpej/0bcc653138377dbe7dee to your computer and use it in GitHub Desktop.
Save maplethorpej/0bcc653138377dbe7dee to your computer and use it in GitHub Desktop.
Super Simple Navigation-based jQuery Slider
var navigation = {
setup: function ($container) {
this.onChange($container);
},
onChange: function ($container) {
var $nav = $container.find('.nav li'),
$content = $container.find('.content li');
$nav.on('click', function () {
var target = $(this).index();
$nav.removeClass('active');
$(this).addClass('active');
$content.hide();
$content.eq(target).fadeIn();
});
}
};
$(document).ready(function () {
navigation.setup($('.container'));
/* Simply specify the container element
and follow the proper structure below. */
});
/*
STRUCTURE
.container
> ul.nav
>> li (1)
>> li (2)
> ul.content
>> li (1)
>> li (2)
NOTE: .nav li (n) cooresponds with .content li (n)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment