Skip to content

Instantly share code, notes, and snippets.

@gbrock
Created May 16, 2015 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbrock/b865717786c154ebd0fd to your computer and use it in GitHub Desktop.
Save gbrock/b865717786c154ebd0fd to your computer and use it in GitHub Desktop.
mJEEBW
<ul class="selector">
<li data-name="red">Red</li>
<li data-name="blue">Blue</li>
</ul>
<ul class="people">
<li class="red">
Ann
<p>Lorem ipsum</p>
</li>
<li class="red">
Terry
</li>
<li class="blue">
Bettina
</li>
</ul>
$('.selector li').click(function () {
$(this).siblings().removeClass('active');
$(this).addClass('active');
var name = $(this).attr('data-name');
var nodes = $('.people li');
nodes.hide();
nodes.filter('.' + name).show();
});
$(document).on('click', '.selector li.active', function () {
$(this).parent().children().removeClass('active');
var nodes = $('.people li');
nodes.show();
});
.selector {
li {
display: inline;
list-style: none;
&.active {
font-weight: bold;
}
}
}
.people {
li {
width: 200px;
float: left;
list-style: none;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment