Created
October 12, 2014 11:11
-
-
Save wub/40d4e26a5196c0730586 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<ul class="tabs"> | |
<li data-display="foo">FOO</li> | |
<li data-display="bar">BAR</li> | |
<li data-display="baz">BAZ</li> | |
</ul> | |
<div class="tab" data-content="foo"> | |
Foo content | |
</div> | |
<div class="tab" data-content="bar"> | |
Bar content | |
</div> | |
<div class="tab" data-content="baz"> | |
Baz content | |
</div> | |
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> | |
<script> | |
$tabs = $('.tabs li'); | |
$(document).on('click', $tabs, function (e) { | |
tab = $(e.target); | |
$tabs.removeClass('active'); | |
tab.addClass('active'); | |
$('.tab').hide(); | |
$('[data-content="'+ tab.data('display') +'"').show(); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment