Created
August 6, 2015 15:52
-
-
Save maplethorpej/0bcc653138377dbe7dee to your computer and use it in GitHub Desktop.
Super Simple Navigation-based jQuery Slider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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